Skip to content

Instantly share code, notes, and snippets.

Last active November 13, 2016 20:02
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
#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+";")
plane = "pPlane"+str(iteration)
maya.mel.eval("select -r "+plane+";")
maya.mel.eval("createNCloth 1;")
plane = 'polySurface'+str(iteration) ".vtx[60]", add=True) ".vtx[70]", add=True) ".vtx[59]", add=True) ".vtx[71]", add=True) ".vtx[49]", add=True) ".vtx[50]", add=True) ".vtx[61]", add=True)".vtx[381]", add=True)
for i in range(360, 380):".vtx["+str(i)+"]", add=True), add=True), 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