def createNCloth(mesh, nucleus='', worldSpace=False, prefix=''): ''' Create an nCloth object from the specified mesh. @param mesh: Mesh to create nCloth from @type mesh: str @param nucleus: nucleus to attach nCloth to @type nucleus: str @param worldSpace: nCloth deformations in local or world space @type worldSpace: str @param prefix: Name prefix for created nodes @type prefix: str ''' # Check mesh if not glTools.utils.mesh.isMesh(mesh): raise Exception('Object "' + mesh + '" is not a valid mesh!') # Check prefix if not prefix: if mesh.count('_'): prefix = glTools.utils.stringUtils.stripSuffix(mesh) else: prefix = mesh # Check nucleus if nucleus: if not isNucleus(nucleus): print('Object "' + nucleus + '" is not a valid nucleus. Using current active nucleus!') getActiveNucleus(nucleus) # Set active nucleus setActiveNucleus(nucleus) # Create nCloth from mesh mc.select(mesh) nClothShape = mm.eval('createNCloth ' + str(int(worldSpace))) nCloth = mc.listRelatives(nClothShape, p=True)[0] # Rename nCloth nCloth = mc.rename(nCloth, prefix + '_nCloth') nClothShape = mc.listRelatives(nCloth, s=True)[0] # Get outMesh outMesh = mc.listConnections(nClothShape + '.outputMesh', s=False, d=True, sh=True)[0] outMesh = mc.rename(outMesh, mesh + 'ClothShape') # return result return nCloth
def createNCloth(mesh,nucleus='',worldSpace=False,prefix=''): ''' Create an nCloth object from the specified mesh. @param mesh: Mesh to create nCloth from @type mesh: str @param nucleus: nucleus to attach nCloth to @type nucleus: str @param worldSpace: nCloth deformations in local or world space @type worldSpace: str @param prefix: Name prefix for created nodes @type prefix: str ''' # Check mesh if not glTools.utils.mesh.isMesh(mesh): raise Exception('Object "'+mesh+'" is not a valid mesh!') # Check prefix if not prefix: if mesh.count('_'): prefix = glTools.utils.stringUtils.stripSuffix(mesh) else: prefix = mesh # Check nucleus if nucleus: if not isNucleus(nucleus): print('Object "'+nucleus+'" is not a valid nucleus. Using current active nucleus!') getActiveNucleus(nucleus) # Set active nucleus setActiveNucleus(nucleus) # Create nCloth from mesh mc.select(mesh) nClothShape = mm.eval('createNCloth '+str(int(worldSpace))) nCloth = mc.listRelatives(nClothShape,p=True)[0] # Rename nCloth nCloth = mc.rename(nCloth,prefix+'_nCloth') nClothShape = mc.listRelatives(nCloth,s=True)[0] # Get outMesh outMesh = mc.listConnections(nClothShape+'.outputMesh',s=False,d=True,sh=True)[0] outMesh = mc.rename(outMesh,mesh+'ClothShape') # return result return nCloth
def createNRigid(mesh, nucleus='', prefix=''): ''' Create an nRigid object from the specified mesh. @param mesh: Mesh to create nRigid from @type mesh: str @param nucleus: nucleus to attach nRigid to @type nucleus: str @param prefix: Name prefix for created nodes @type prefix: str ''' # Check mesh if not glTools.utils.mesh.isMesh(mesh): raise Exception('Object "' + mesh + '" is not a valid mesh!') # Check prefix if not prefix: if mesh.count('_'): prefix = glTools.utils.stringUtils.stripSuffix(mesh) else: prefix = mesh # Check nucleus if nucleus: if not isNucleus(nucleus): print('Object "' + nucleus + '" is not a valid nucleus. Using current active nucleus!') getActiveNucleus(nucleus) # Set active nucleus setActiveNucleus(nucleus) # Create nRigid from mesh mc.select(mesh) nRigidShape = mm.eval('makeCollideNCloth') nRigid = mc.listRelatives(nRigidShape, p=True, pa=True)[0] # Rename nCloth nRigid = mc.rename(nRigid, prefix + '_nRigid') # Return result return nRigid
def createNRigid(mesh,nucleus='',prefix=''): ''' Create an nRigid object from the specified mesh. @param mesh: Mesh to create nRigid from @type mesh: str @param nucleus: nucleus to attach nRigid to @type nucleus: str @param prefix: Name prefix for created nodes @type prefix: str ''' # Check mesh if not glTools.utils.mesh.isMesh(mesh): raise Exception('Object "'+mesh+'" is not a valid mesh!') # Check prefix if not prefix: if mesh.count('_'): prefix = glTools.utils.stringUtils.stripSuffix(mesh) else: prefix = mesh # Check nucleus if nucleus: if not isNucleus(nucleus): print('Object "'+nucleus+'" is not a valid nucleus. Using current active nucleus!') getActiveNucleus(nucleus) # Set active nucleus setActiveNucleus(nucleus) # Create nRigid from mesh mc.select(mesh) nRigidShape = mm.eval('makeCollideNCloth') nRigid = mc.listRelatives(nRigidShape,p=True,pa=True)[0] # Rename nCloth nRigid = mc.rename(nRigid,prefix+'_nRigid') # Return result return nRigid