本文整理汇总了Python中maya.cmds.deformer函数的典型用法代码示例。如果您正苦于以下问题:Python deformer函数的具体用法?Python deformer怎么用?Python deformer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deformer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getGeoIndex
def getGeoIndex(dfm, geo):
"""
return index of geometry in deformer
geo - should be a shape node
"""
deformedGeos = mc.deformer(dfm, q=True, g=True)
geoId = deformedGeos.index(geo)
deformedGeosId = mc.deformer(dfm, q=True, gi=True)
return deformedGeosId[geoId]
示例2: createCmd
def createCmd():
"""Create node."""
geo = _getGeoFromUI()
rbsNode = geo and _getRbs(geo)
if rbsNode:
_updateUI()
return
# create the rbs
cmds.deformer(geo, typ=_rbsNodeName, foc=True)
_updateUI()
示例3: apply_push_deformer_selection
def apply_push_deformer_selection():
if not self.__load_plugin():
return
objs = cmds.ls(sl=True, type='transform')
if not len(objs):
cmds.warning('No objects selected.')
return
for x in objs:
cmds.select(x)
name = str(x) + '_pushDeformer'
name = mel.eval('formValidObjectName(\"{0}\");'.format(name))
cmds.deformer(name=name, type='pushDeformer')
示例4: pruneWeights
def pruneWeights(deformer, geoList=[], threshold=0.001):
"""
Set deformer component weights to 0.0 if the original weight value is below the set threshold
@param deformer: Deformer to removed components from
@type deformer: str
@param geoList: The geometry objects whose components are checked for weight pruning
@type geoList: list
@param threshold: The weight threshold for removal
@type threshold: str
"""
# Check deformer
if not cmds.objExists(deformer):
raise Exception('Deformer "' + deformer + '" does not exist!')
# Check geometry
if type(geoList) == str: geoList = [geoList]
if not geoList: geoList = cmds.deformer(deformer, q=True, g=True)
if not geoList: raise Exception('No geometry to prune weight for!')
for geo in geoList:
if not cmds.objExists(geo):
raise Exception('Geometry "' + geo + '" does not exist!')
# For each geometry
for geo in geoList:
# Get deformer member indices
memberIndexList = getDeformerSetMemberIndices(deformer, geo)
# Get weight list
weightList = getWeights(deformer, geo)
# Prune weights
pWeightList = [wt if wt > threshold else 0.0 for wt in weightList]
# Apply pruned weight list
setWeights(deformer, pWeightList, geo)
示例5: importAssetCache
def importAssetCache(self, cacheXmlLt, cacheErrorCheck = False):
""" cacheXmlLt = "R:/data/cache/sq001/sh001/light/char/ben00c_ben/ben00c_ben.xml" """
if os.path.exists(cacheXmlLt):
cacheChannels = mc.cacheFile(fileName=cacheXmlLt,q=1,channelName=1)
cacheGeos = self.getCacheGeos()
cacheGeoDict, cacheChannelsTmp = {}, []
for chn in cacheChannels:
for geo in cacheGeos:
baseChn = utils.stripNames(utils.convertName(chn, "texture"))
baseGeo = utils.stripNames(utils.stripNames(geo, ":"), "|")
if baseChn in baseGeo:
cacheGeoDict[chn] = geo
cacheChannelsTmp.append(chn)
continue
else:
utils.msgWin("Error", "File does not exist : %s"%cacheXmlLt, self.silent)
return False
if cacheErrorCheck:
missedChannels = list(set(cacheChannels).difference(set(cacheGeoDict.keys())))
if len(missedChannels) > 0:
msg = "Cache geometry missing\n"
msg += "\n".join(missedChannels)
utils.msgWin("Error", msg, self.silent)
return missedChannels
else:
return False
for chNode in self.getCacheNodes():
mc.delete(chNode)
for chn in cacheGeoDict.keys():
deformShp = cacheGeoDict[chn]
try:
shpSwitch = mc.deformer(deformShp, type="historySwitch")
except:
continue
shpHist = mc.listHistory(deformShp, pdo=1)
if shpHist:
for hist in shpHist:
if mc.nodeType(hist) == "tweak":
dblList = mc.listAttr("%s.plist"%hist, m= 1)
fltList = mc.listAttr("%s.vlist"%hist, m= 1)
dbCon, flCon = False, False
if dblList:
if len(dblList) > 1: dbCon = True
if fltList:
if len(fltList) > 1: flCon = True
if not(dbCon or flCon):
mc.delete(hist)
break
conns = mc.listConnections("%s.ip[0].ig"%shpSwitch[0], p=1)
mc.connectAttr(conns[0], "%s.ug[0]"%shpSwitch[0])
mc.setAttr("%s.playFromCache"%shpSwitch[0], 1)
mc.getAttr("%s.op[0]"%shpSwitch[0], sl = 1)
mc.setAttr("%s.playFromCache"%shpSwitch[0], 0)
mc.disconnectAttr(conns[0], "%s.ug[0]"%shpSwitch[0])
switch = mc.rename(shpSwitch[0],'cacheSwitch#')
mc.setAttr(switch+'.ihi',0)
cacheNode = mc.cacheFile(f = cacheXmlLt, attachFile = True, ia = '%s.inp[0]'%switch, cnm = chn)
mc.connectAttr(cacheNode+".inRange", switch + '.playFromCache')
utils.msgWin("Message", "Cache loaded successfully for %s"%self.namespace, self.silent)
return True
示例6: addModification
def addModification( meshObjs ):
import sgBFunction_attribute
import sgBFunction_dag
meshObjs = sgBFunction_dag.getChildrenMeshExists( meshObjs )
softMod = cmds.deformer( meshObjs, type='softMod' )[0]
ctlGrp = cmds.createNode( 'transform' )
cmds.setAttr( ctlGrp+'.dh', 1 )
dcmp = cmds.createNode( 'decomposeMatrix' )
ctl = cmds.sphere()[0]
ctl = cmds.parent( ctl, ctlGrp )[0]
sgBFunction_attribute.addAttr( ctl, ln='__________', at='enum', enumName = ':Modify Attr', cb=1 )
sgBFunction_attribute.addAttr( ctl, ln='falloffRadius', min=0, dv=1, k=1 )
sgBFunction_attribute.addAttr( ctl, ln='envelope', min=0, max=1, dv=1, k=1 )
cmds.connectAttr( ctlGrp+'.wim', softMod+'.bindPreMatrix' )
cmds.connectAttr( ctlGrp+'.wm', softMod+'.preMatrix' )
cmds.connectAttr( ctl+'.wm', softMod+'.matrix' )
cmds.connectAttr( ctl+'.m', softMod+'.weightedMatrix' )
cmds.connectAttr( ctlGrp+'.wm', dcmp+'.imat' )
cmds.connectAttr( dcmp+'.ot', softMod+'.falloffCenter' )
for i in range( len( meshObjs ) ):
cmds.connectAttr( meshObjs[i]+'.wm', softMod+'.geomMatrix[%d]' % i )
cmds.connectAttr( ctl+'.envelope', softMod+'.envelope' )
cmds.connectAttr( ctl+'.falloffRadius', softMod+'.falloffRadius' )
cmds.xform( ctlGrp, ws=1, t=cmds.getAttr( meshObjs[0]+'.wm' )[-4:-1] )
cmds.select( ctlGrp )
示例7: makeWire
def makeWire( dropoffDistance ):
sels = cmds.ls( sl=1 )
last = sels[-1]
lastShape = cmds.listRelatives( last, s=1 )[0]
baseShape = getBaseShape( last )
for sel in sels[:-1]:
wireExists = False
hists = cmds.listHistory( sel, pdo=1 )
if not hists: hists = []
for hist in hists:
if cmds.nodeType( hist ) == 'wire':
wireExists = True
break
if wireExists:
wire = hist
else:
wire = cmds.deformer( sel, type='wire' )[0]
cmds.connectAttr( baseShape+'.local', wire+'.baseWire[0]' )
cmds.connectAttr( lastShape+'.local', wire+'.deformedWire[0]' )
cmds.setAttr( wire+'.dropoffDistance[0]', dropoffDistance )
cmds.select( sels )
示例8: mirrorDeformer
def mirrorDeformer(middleEdge,deformer,search='lf',replace='rt'):
'''
'''
# Load plugin
loadPlugin()
# Get Mesh Data
mesh = mc.ls(middleEdge,o=True)[0]
vmap = mm.eval('edgeFlowMirror -task "getMapArray" -middleEdge '+middleEdge)
# Mirror Membership
mem = glTools.utils.deformer.getDeformerSetMemberIndices(deformer,mesh)
if len(vmap) > len(mem): mem = sorted([vmap[i] for i in mem])
mem = [mesh+'.vtx['+str(i)+']' for i in mem]
# Create Mirror Deformer
deformerType = mc.objectType(deformer)
deformerName = deformer
if deformerName.startswith(search): deformerName = deformerName.replace(search,replace)
elif deformerName.startswith(replace): deformerName = deformerName.replace(replace,search)
else: deformerName = deformerName+'_mirror'
mDeformer = mc.deformer(mem,type=deformerType,name=deformerName)[0]
# Mirror Deofmer Weights
mirrorDeformerWeights(middleEdge,deformer,dstDeformer=mDeformer)
# Return Result
return mDeformer
示例9: matchCurveShapes_andShrinkWrap
def matchCurveShapes_andShrinkWrap(self, getFirstGrp, getSecondGrp):
myDict={
".shapePreservationEnable":1,
".shapePreservationSteps":72,
".shapePreservationReprojection":1,
".shapePreservationIterations":1,
".shapePreservationMethod":0,
".envelope":1,
".targetSmoothLevel":1,
".continuity":1,
".keepBorder":0,
".boundaryRule":1,
".keepHardEdge":0,
".propagateEdgeHardness":0,
".keepMapBorders":1,
".projection":4,
".closestIfNoIntersection":0,
".closestIfNoIntersection":0 ,
".reverse":0,
".bidirectional":0,
".boundingBoxCenter":1,
".axisReference":0 ,
".alongX":1,
".alongY":1,
".alongZ":1,
".offset":0,
".targetInflation":0,
".falloff":0.3021390379,
".falloffIterations": 1
}
cmds.delete(getFirstGrp, ch=1)
getShrink=cmds.deformer(getFirstGrp, type="shrinkWrap")
cmds.connectAttr(getSecondGrp+".worldMesh[0]", getShrink[0]+".targetGeom", f=1)
for key, value in myDict.items():
cmds.setAttr(getShrink[0]+key, value)
示例10: ShapeInverterCmdold
def ShapeInverterCmdold(base=None, corrective=None, name=None):
mc.undoInfo(openChunk=True)
if not base or not corrective:
sel = mc.ls(sl=True)
base, corrective = sel
shapes = mc.listRelatives(base, children=True, shapes=True)
for s in shapes:
if mc.getAttr("%s.intermediateObject" % s) and mc.listConnections("%s.worldMesh" % s, source=False):
origMesh = s
break
deformed = mc.polyPlane(ch=False)[0]
mc.connectAttr("%s.worldMesh" % origMesh, "%s.inMesh" % deformed)
mc.setAttr("%s.intermediateObject" % origMesh, 0)
mc.delete(deformed, ch=True)
mc.setAttr("%s.intermediateObject" % origMesh, 1)
if not name:
name = "%s_inverted#" % corrective
invertedShape = duplicateMesh(base, name=name)
deformer = mc.deformer(invertedShape, type="ShapeInverter")[0]
mc.ShapeInverterCmd(baseMesh=base, invertedShape=invertedShape, ShapeInverterdeformer=deformer, origMesh=deformed)
# correctiveShape = duplicateMesh(base,name=corrective+"_corrective#")
# mc.connectAttr('%s.outMesh' % getShape(correctiveShape), '%s.correctiveMesh' % deformer)
# transferMesh(corrective,[correctiveShape])
mc.connectAttr("%s.outMesh" % getShape(corrective), "%s.correctiveMesh" % deformer)
mc.setAttr("%s.activate" % deformer, True)
mc.delete(deformed)
bdingBx = mc.polyEvaluate(corrective, boundingBox=True)
xDifVal = bdingBx[0][1] - bdingBx[0][0]
# mc.move(xDifVal*1.10,correctiveShape,r=True,moveX=True)
mc.move(xDifVal * 2.20, invertedShape, r=True, moveX=True)
mc.undoInfo(closeChunk=True)
return invertedShape # ,correctiveShape
示例11: importPolyMesh
def importPolyMesh(name, identifier, jobInfo, parentXform=None, isConstant=False, useDynTopo=False):
cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importPolyMesh")
# TODO: set isConstant properly elsewhere when there are no transforms but are
# animated attributes
isConstant = False
try:
reader = ""
shape = fnt.alembicCreateNode(name, "mesh", parentXform)
cmds.sets(shape, e=True, forceElement="initialShadingGroup")
topoReader = cmds.createNode("ExocortexAlembicPolyMesh")
cmds.connectAttr(topoReader+".outMesh", shape+".inMesh")
cmds.connectAttr(jobInfo.filenode+".outFileName", topoReader+".fileName")
cmds.setAttr(topoReader+".identifier", identifier, type="string")
cmds.setAttr(topoReader+".normals", jobInfo.useNormals)
cmds.setAttr(topoReader+".uvs", jobInfo.useUVs)
if jobInfo.useFaceSets:
cmds.ExocortexAlembic_createFaceSets(o=shape, f=jobInfo.filename, i=identifier)
if useDynTopo:
cmds.connectAttr(jobInfo.timeCtrl+".outTime", topoReader+".inTime")
reader = topoReader
elif not isConstant:
reader = cmds.deformer(shape, type="ExocortexAlembicPolyMeshDeform")[0]
setupReaderAttribute(reader, identifier, isConstant, jobInfo)
#if not useDynTopo:
# setupReaderAttribute(topoReader, identifier, isConstant, jobInfo)
except:
return [traceback.format_exc()]
finally:
cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importPolyMesh")
return [shape, reader]
示例12: create
def create(self,targetList,influenceList,defaultWeightVal=1.0,maxDist=0.0,name='surfaceSkin1'):
"""
Create surfaceSkin deformer for the given target list or selection
@param targetList: list of shapes to bind using surfaceSkin
@type targetList: list
@param influenceList: list of influences to affect surfaceSkin
@type influenceList: list
@param defaultWeightVal: Default influence weight value assigned to components
@type defaultWeightVal: float
@param maxDist: Maximum distance to search for components to affect, from the influence surface
@type maxDist: float
@param name: Name for new surfaceSkin node
@type name str
"""
# Load plugin
if not mc.pluginInfo('isoMuscle',l=1,q=1):
try: mc.loadPlugin('isoMuscle')
except: raise MissingPluginError('Unable to load surfaceSkin (isoMuscle) plugin!!')
# Create Deformer
surfaceSkin = mc.deformer(targetList,type='surfaceSkin',n=name)[0]
# Add influences
self.addInfluence(influenceList,surfaceSkin,defaultWeightVal,maxDist,calculatePrebind=False)
# Ensure surfaceSkin::paintWeight and surfaceSkin::weights are paintable attrs
self.makePaintable()
# Return result
return surfaceSkin
示例13: importPolyMesh
def importPolyMesh(name, identifier, jobInfo, parentXform=None, isConstant=False, useDynTopo=False):
cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._import.importPolyMesh")
try:
reader = ""
shape = fnt.alembicCreateNode(name, "mesh", parentXform)
cmds.sets(shape, e=True, forceElement="initialShadingGroup")
topoReader = cmds.createNode("ExocortexAlembicPolyMesh")
cmds.connectAttr(topoReader+".outMesh", shape+".inMesh")
cmds.connectAttr(jobInfo.filenode+".outFileName", topoReader+".fileName")
cmds.setAttr(topoReader+".identifier", identifier, type="string")
cmds.setAttr(topoReader+".normals", jobInfo.useNormals)
cmds.setAttr(topoReader+".uvs", jobInfo.useUVs)
if jobInfo.useFaceSets:
cmds.ExocortexAlembic_createFaceSets(o=shape, f=jobInfo.filename, i=identifier)
if useDynTopo:
cmds.connectAttr(jobInfo.timeCtrl+".outTime", topoReader+".inTime")
reader = topoReader
elif not isConstant:
reader = cmds.deformer(shape, type="ExocortexAlembicPolyMeshDeform")[0]
setupReaderAttribute(reader, identifier, isConstant, jobInfo)
#if not useDynTopo:
# setupReaderAttribute(topoReader, identifier, isConstant, jobInfo)
except Exception as ex:
shape = "?importPolyMesh --> exception: \"" + str(ex.args) + "\" of type " + str(type(ex));
apix.MPxCommand.setResult(shape)
cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._import.importPolyMesh")
return shape
示例14: attachPolyMesh
def attachPolyMesh(name, identifier, jobInfo, isConstant=False):
cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._attach.attachPolyMesh")
try:
if cmds.objectType(name) != "mesh":
return ["!", "Only mesh can be attached too!"]
conX = cmds.listConnections(name, d=False, type="ExocortexAlembicPolyMeshDeform")
if conX: # it's already attached to a deform, simply change the file reference
polyObj = conX[0]
attachTimeAndFile(polyObj, jobInfo, isConstant)
return [polyObj]
# create deformer, and attach time and file
newDform = cmds.deformer(name, type="ExocortexAlembicPolyMeshDeform")[0]
cmds.setAttr(newDform + ".identifier", identifier, type="string")
attachTimeAndFile(newDform, jobInfo, isConstant)
if jobInfo.useFaceSets:
cmds.ExocortexAlembic_createFaceSets(
f=cmds.getAttr(jobInfo.filenode + ".outFileName"), i=identifier, o=name
)
except:
return ["!", traceback.format_exc()]
finally:
cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._attach.attachPolyMesh")
return [newDform]
示例15: attachCurves
def attachCurves(name, identifier, jobInfo, isConstant=False):
cmds.ExocortexAlembic_profileBegin(f="Python.ExocortexAlembic._attach.attachCurves")
try:
conX = cmds.listConnections(
name + ".create", d=False, type="ExocortexAlembicCurvesDeform"
) or cmds.listConnections(name + ".create", d=False, type="ExocortexAlembicCurves")
if conX:
curObj = conX[0]
attachTimeAndFile(curObj, jobInfo, isConstant)
return [curObj]
# create deformer, and attach time and file
newDform = cmds.deformer(name, type="ExocortexAlembicCurvesDeform")[0]
cmds.setAttr(newDform + ".identifier", identifier, type="string")
attachTimeAndFile(newDform, jobInfo, isConstant)
# get curObj new "output" attribute connection
conX = cmds.listConnections(name + ".create", d=False, type="ExocortexAlembicCurvesDeform")
if conX:
curObj = conX[0]
originalCur = cmds.connectionInfo(curObj + ".output", sfd=True).split(".")[0]
cmds.delete(curObj)
curObj = cmds.createNode("ExocortexAlembicCurves")
attachTimeAndFile(curObj, jobInfo, isConstant)
cmds.connectAttr(curObj + ".outCurve", originalCur + ".create")
cmds.connectAttr(jobInfo.filenode + ".outFileName", curObj + ".fileName")
cmds.setAttr(curObj + ".identifier", identifier, type="string")
except:
return ["!", traceback.format_exc()]
finally:
cmds.ExocortexAlembic_profileEnd(f="Python.ExocortexAlembic._attach.attachCurves")
return [curObj]