/dynamicconstraint.py Secret
Last active
November 13, 2016 20:02
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#creates an an cloth from a plane "pPlane1" and a collider from "pSphere1" and constrains the two so the cloth follows the sphere. | |
import maya.cmds as cmd | |
import maya.mel | |
iteration = 1 | |
sphere = "pSphere"+str(iteration) | |
xhips = cmd.getAttr(sphere+".translateX", asString=False) | |
yhips = cmd.getAttr(sphere+".translateY", asString=False) | |
zhips = cmd.getAttr(sphere+".translateZ", asString=False) | |
cmd.spaceLocator( n="loco"+str(iteration), p=(xhips, yhips, zhips)) | |
cmd.parent('loco'+str(iteration), sphere) | |
maya.mel.eval("select -r "+sphere+";") | |
maya.mel.eval("makeCollideNCloth;") | |
plane = "pPlane"+str(iteration) | |
maya.mel.eval("select -r "+plane+";") | |
maya.mel.eval("createNCloth 1;") | |
plane = 'polySurface'+str(iteration) | |
cmd.select(cl=True) | |
cmd.select(plane+ ".vtx[60]", add=True) | |
cmd.select(plane+ ".vtx[70]", add=True) | |
cmd.select(plane+ ".vtx[59]", add=True) | |
cmd.select(plane+ ".vtx[71]", add=True) | |
cmd.select(plane+ ".vtx[49]", add=True) | |
cmd.select(plane+ ".vtx[50]", add=True) | |
cmd.select(plane+ ".vtx[61]", add=True) | |
cmd.select(sphere+".vtx[381]", add=True) | |
for i in range(360, 380): | |
cmd.select(sphere+".vtx["+str(i)+"]", add=True) | |
cmd.select(plane, add=True) | |
cmd.select(sphere, add=True) | |
maya.mel.eval("createNConstraint transform 0;") | |
cmd.parent('dynamicConstraint'+str(iteration), 'loco'+str(iteration)) | |
maya.mel.eval('setAttr "nClothShape'+str(iteration)+'.stretchResistance" 2.455;') | |
maya.mel.eval('setAttr "nClothShape'+str(iteration)+'.compressionResistance" 0.03;') | |
maya.mel.eval('setAttr "nClothShape'+str(iteration)+'.bendResistance" 0.03;') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment