本文整理汇总了Python中maya.cmds.listHistory函数的典型用法代码示例。如果您正苦于以下问题:Python listHistory函数的具体用法?Python listHistory怎么用?Python listHistory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listHistory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FilterNodeType
def FilterNodeType(self, type):
'''
返回所选择物体的shader,也可以直接选择shader
'''
outputNodeList = []
for input in self.sl :
inputType = cmds.nodeType(input)
if inputType == type:
outputNodeList.append(input)
elif inputType == 'transform' or inputType == "mesh" or inputType == "nurbsSurface" :
shapeList = cmds.listRelatives(input, ad=1, pa=1, type='surfaceShape')
shapeList = sorted(set(shapeList), key=shapeList.index) #去除列表中的重复元素
for shape in shapeList:
sg = cmds.listConnections(shape, type='shadingEngine')
if sg[0] != 'initialShadingGroup' and len(sg):
shadingNetwork = cmds.listHistory(sg[0], pdo=1)
if len(shadingNetwork):
for outputNode in shadingNetwork:
if cmds.nodeType(outputNode) == type:
outputNodeList.append(outputNode)
else:
shadingNetwork = cmds.listHistory(input, pdo=1)
if len(shadingNetwork):
for outputNode in shadingNetwork:
if cmds.nodeType(outputNode) == type:
outputNodeList.append(outputNode)
self.outputNodeList = sorted(set(outputNodeList), key=outputNodeList.index)
示例2: copyWeight
def copyWeight( first, second ):
hists = cmds.listHistory( first, pdo=1 )
skinNode = None
for hist in hists:
if cmds.nodeType( hist ) == 'skinCluster':
skinNode = hist
if not skinNode: return None
targetSkinNode = None
targetHists = cmds.listHistory( second, pdo=1 )
if targetHists:
for hist in targetHists:
if cmds.nodeType( hist ) == 'skinCluster':
targetSkinNode = hist
if not targetSkinNode:
bindObjs = cmds.listConnections( skinNode+'.matrix', s=1, d=0, type='joint' )
bindObjs.append( second )
print bindObjs
cmds.skinCluster( bindObjs, tsb=1 )
cmds.copySkinWeights( first, second, noMirror=True, surfaceAssociation='closestPoint', influenceAssociation ='oneToOne' )
示例3: findTypeInHistory
def findTypeInHistory(obj, type, future=False, past=True):
# This is translated from the mel procedure of the same name.
if past and future:
# In the case that the object type exists in both past and future
# find the one that is fewer connections away.
pasts = cmds.listHistory(obj, f=0, bf=1, af=1)
futures = cmds.listHistory(obj, f=1, bf=1, af=1)
pastObjs = cmds.ls(pasts, type=type)
futureObjs = cmds.ls(futures, type=type)
if len(pastObjs) > 0:
if len(futureObjs) > 0:
for i in range( min( len(pasts), len(futures) ) ):
if pasts[i] == pastObjs[0]:
return pastObjs[0]
if futures[i] == futureObjs[0]:
return futureObjs[0]
else:
return pastObjs[0]
elif len(futureObjs) > 0:
return futureObjs[0]
else:
if past:
hist = cmds.listHistory(obj, f=0, bf=1, af=1)
objs = cmds.ls(hist, type=type)
if len(objs) > 0:
return objs[0]
if future:
hist = cmds.listHistory(obj, f=1, bf=1, af=1)
objs = cmds.ls(hist, type=type)
if len(objs) > 0:
return objs[0]
return None
示例4: meshesFromHistory
def meshesFromHistory(control):
'''
Return all visible meshes downstream from a given control.
'''
#try searching backward first for speed
meshes = []
allMeshes = mc.ls(type='mesh')
for mesh in allMeshes:
hist = mc.listHistory(mesh, allConnections=True)
if control in hist:
if isNodeVisible(mesh):
meshes.append(mesh)
if meshes:
return meshes
#if we didn't find any, search forward from control
#this takes a bit longer
hier = mc.listRelatives(control, ad=True, pa=True)
if not hier:
hier = [control]
else:
hier.append(control)
hist = mc.listHistory(hier, future=True, allFuture=True, allConnections=True)
hist = list(set(hist))
meshes = mc.ls(hist, type='mesh')
meshes = [x for x in meshes if isNodeVisible(x)]
return meshes
示例5: isAffected
def isAffected(nodeAffected, nodeDriver):
driverFamily = cmds.ls(nodeDriver, dagObjects=True)
if nodeAffected in driverFamily: return True
nodeAffectedConnections = cmds.listHistory(nodeAffected)
if nodeDriver in nodeAffectedConnections: return True
steps1to3=set()
steps1to3.update(steps1and3)
step4=[]
for each in (cmds.ls(list(steps1to3),shapes=True)):
try:
step4.extend(cmds.listConnections(each+'.instObjGroups', t='shadingEngine', et=1))
except TypeError:
pass
steps1to3.update(step4)
steps1to4=set()
steps1to4.update(steps1to3)
steps1to4.update(step4)
step5=set(steps1to4)
step5.update(cmds.listHistory(list(steps1to4)))
print step5
示例6: getHIKCharacterNode_from_node
def getHIKCharacterNode_from_node(_node):
if type(_node) == str or type(_node) == unicode:
# namespace 확인
_namespace = getNamespace(_node)
_ls = []
if _namespace:
# namespace가 존재할경우
# 레퍼런스로 생각하고 namespace로 시작하는 HIKProperty2State 노드 찾음.
_ls = cmds.ls( _namespace+"*", type='HIKCharacterNode')
else:
# namespace가 존재하지 않을경우
# 임포트되었거나, 캐릭터 원본 파일
# listHistory 를 사용해서 찾음,
# 일일히 다 검색해야 해서, 다소 피드백이 느림.
_listHistory = cmds.listHistory(
_node,
#allFuture=True,
allConnections=True
)
_ls = cmds.ls( _listHistory, type='HIKCharacterNode')
# 찾은게 없으면 나감
if not _ls:
return
# 찾은게 있으면 등록
return _ls[0]
elif type(_node) == list:
_HIKCharacterNode = []
for _n in _node:
_namespace = getNamespace(_n)
_ls = []
if _namespace:
# namespace가 존재할경우
# 레퍼런스로 생각하고 namespace로 시작하는 HIKProperty2State 노드 찾음.
_ls = cmds.ls( _namespace+"*", type='HIKCharacterNode')
else:
# namespace가 존재하지 않을경우
# 임포트되었거나, 캐릭터 원본 파일
# listHistory 를 사용해서 찾음,
# 일일히 다 검색해야 해서, 다소 피드백이 느림.
_listHistory = cmds.listHistory(
_n,
#allFuture=True,
allConnections=True
)
_ls = cmds.ls( _listHistory, type='HIKCharacterNode')
# 찾은게 없으면 나감
if not _ls: return
for _i in _ls:
_HIKCharacterNode.append(_i)
return list(set(_HIKCharacterNode))
示例7: cmdSelectSgWobbleCurve
def cmdSelectSgWobbleCurve( *args ):
sgWobbleCurves = []
for hist in cmds.listHistory( cmds.ls( sl=1 ), pdo=1 ):
if cmds.nodeType( hist ) != 'wire': continue
targetCrv = cmds.listConnections( hist+'.deformedWire[0]' )
crvHists = cmds.listHistory( targetCrv, pdo=1 )
for crvHist in crvHists:
if cmds.nodeType( crvHist ) != 'sgWobbleCurve2': continue
sgWobbleCurves.append( crvHist )
if sgWobbleCurves: cmds.select( sgWobbleCurves )
示例8: cmdSelectFollicle
def cmdSelectFollicle( *args ):
upObjects = []
for hist in cmds.listHistory( cmds.ls( sl=1 ), pdo=1 ):
if cmds.nodeType( hist ) != 'wire': continue
targetCrv = cmds.listConnections( hist+'.deformedWire[0]' )
crvHists = cmds.listHistory( targetCrv, pdo=1 )
for crvHist in crvHists:
if cmds.nodeType( crvHist ) != 'sgWobbleCurve2': continue
mm = cmds.listConnections( crvHist+'.aimMatrix' )[0]
upObj = cmds.listConnections( mm+'.matrixIn[0]' )[0]
upObjects.append( upObj )
if upObjects: cmds.select( upObjects )
示例9: findTypeInHistory
def findTypeInHistory(obj, objType, future=False, past=False):
"""
returns the node of the specified type that is the closest traversal to the input object
:param obj: Object name
:type obj: str
:param objType: Object type list
:type objType: str | list
:param future: Future depth
:type future: bool
:param past: Past depth
:type past: bool
:return: Connected objType nodes
:rtype: list
"""
#// Test with list return instead of closest connected node
#// Replace return pastObjs with return pastObjs[0] etc
if past and future:
#// In the case that the object type exists in both past and future,
#// find the one that is fewer connections away.
pastList = mc.listHistory(obj, f=False, bf=True, af=True)
futureList = mc.listHistory(obj, f=True, bf=True, af=True)
pastObjs = mc.ls(pastList, type=objType)
futureObjs = mc.ls(futureList, type=objType)
if pastObjs:
if futureObjs:
mini = len(futureList)
if len(pastList) < mini:
mini = len(pastList)
for i in range(mini):
if pastList[i] in pastObjs:
return pastObjs
if futureList[i] in futureObjs:
return futureObjs
else:
return pastObjs
elif futureObjs:
return futureObjs
else:
if past:
hist = mc.listHistory(obj, f=False, bf=True, af=True)
objs = mc.ls(hist, type=objType)
if objs:
return objs
if future:
hist = mc.listHistory(obj, f=True, bf=True, af=True)
objs = mc.ls(hist, type=objType)
if objs:
return objs
示例10: renameHistoryNodes
def renameHistoryNodes(obj, nodeType, prefix='', suffix='', stripOldSuffix=True):
"""
Rename nodes in a specified objects history based on a given or derived prefix and suffix
@param obj: Object whose history nodes will be renamed
@type obj: str
@param nodeType: Node types to isolate for rename
@type nodeType: str or list
@param prefix: Name prefix for nodes. If empty, derive from object name
@type prefix: str
@param suffix: Name suffix for nodes. If empty, derive from node type
@type suffix: str
"""
# Check object
if not cmds.objExists(obj):
raise Exception('Object "' + obj + '" does not exist!')
# Check prefix
if not prefix:
if stripOldSuffix:
prefix = glTools.utils.stringUtils.stripSuffix(obj)
else:
prefix = obj
# Get object history
if nodeType.lower() == 'all':
nodeHist = cmds.ls(cmds.listHistory(obj))
else:
nodeHist = cmds.ls(cmds.listHistory(obj), type=nodeType)
nodeHist.sort()
# For each history node
nodeCount = len(nodeHist)
for n in range(nodeCount):
# Check suffix
if not suffix:
nodeSuffix = cmds.objectType(nodeHist[n])
else:
nodeSuffix = suffix
# Check index
if nodeCount > 1: nodeSuffix = glTools.utils.stringUtils.stringIndex(n, 1) + '_' + nodeSuffix
# Rename node
nodeHist[n] = cmds.rename(nodeHist[n], prefix + '_' + nodeSuffix)
# Return result
return nodeHist
示例11: exportLights
def exportLights(self):
for light in self.lights:
hisObject = cmds.listHistory(light)
hisObject = hisObject[0]
exportName = light.replace(':', '_')
thisNodeType = cmds.nodeType(hisObject)
parameters = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'cr', 'cg', 'cb', 'intensity', 'rotateOrder']
if thisNodeType == 'spotLight':
writeOutType = 'spot'
parameters.append('coneAngle')
parameters.append('penumbraAngle')
parameters.append('dropoff')
if thisNodeType == 'pointLight':
writeOutType = 'point'
if thisNodeType == 'directionalLight':
writeOutType = 'directional'
for i in range(self.startFrame, self.endFrame+1):
if thisNodeType == 'spotLight':
lightConeAngle = cmds.getAttr(hisObject + '.coneAngle',time=i)
lightPenumbraAngle = cmds.getAttr(hisObject + '.penumbraAngle',time=i)
lightDropoff = cmds.getAttr(hisObject + '.dropoff',time=i)
else:
lightConeAngle = 0
lightPenumbraAngle = 0
lightDropoff = 0
self.exportData(light, parameters, self.startFrame, self.endFrame+1, self.exportPath + exportName + '.fm2n')
print 'Saved data from: ' + light
示例12: createFreeCameras
def createFreeCameras(self):
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'self.cameras: %s' % self.cameras, verbose = False)
for camera in self.cameras:
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'Processing camera: %s' % camera, verbose = False)
cmds.select(camera, r= True)
newCamera = cmds.duplicate( rr=True )
newCamera = newCamera[0]
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'newCamera: %s' % newCamera, verbose = False)
for attr in ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz', 'v']:
cmds.setAttr(newCamera + "." + attr, lock=False)
hisObject = cmds.listHistory(newCamera)
for attr in ['hfa', 'vfa', 'fl', 'lsr', 'fs', 'fd', 'sa', 'coi']:
cmds.setAttr(hisObject[0] + "." + attr, lock=False)
parentNode = cmds.listRelatives(camera, p= True)
if parentNode != None:
cmds.parent( newCamera, world= True)
pointConst = cmds.pointConstraint( camera, newCamera )
orientConst = cmds.orientConstraint( camera, newCamera )
cmds.bakeResults( newCamera+'*', t=(self.startFrame, self.endFrame), simulation=True, sparseAnimCurveBake=False, shape=False)
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'newCamera %s baked successfully...' % newCamera, verbose = False)
cmds.delete(pointConst, orientConst, cn=True )
newCameraName = cmds.rename(newCamera, '%s_Cpy' % camera)
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'newCameraName: %s' % newCameraName, verbose = False)
self.newCameras.extend([newCameraName])
debug(app = None, method = 'FromMaya2Nuke.createFreeCameras', message = 'self.newCameras: %s' % self.newCameras, verbose = False)
示例13: repair
def repair(self, instance):
"""Delete all intermediateObjects"""
intermediate_objects = self.list_intermediate_shapes(instance)
if intermediate_objects:
future = cmds.listHistory(intermediate_objects, future=True)
cmds.delete(future, ch=True)
cmds.delete(intermediate_objects)
示例14: mmSetBindDefault
def mmSetBindDefault( *args ):
sels = cmds.ls( sl=1 )
for sel in sels:
hists = cmds.listHistory( sel )
skinNode = None
for hist in hists:
if cmds.nodeType( hist ) == 'skinCluster':
skinNode = hist
break
fnSkinNode = om.MFnDependencyNode( baseFunctions.getMObject( skinNode ) )
plugMatrix = fnSkinNode.findPlug( 'matrix' )
plugBindPre = fnSkinNode.findPlug( 'bindPreMatrix' )
for i in range( plugMatrix.numElements() ):
loIndex = plugMatrix[i].logicalIndex()
oMtx = plugMatrix[i].asMObject()
mtxData = om.MFnMatrixData( oMtx )
mtx = mtxData.matrix()
invData = om.MFnMatrixData()
oInv = invData.create( mtx.inverse() )
plugBindPre.elementByLogicalIndex( loIndex ).setMObject( oInv )
示例15: findRelatedSkinCluster
def findRelatedSkinCluster(geometry):
'''
Return the skinCluster attached to the specified geometry
Args:
geometry (str): Geometry object/transform to query
Returns:
str
'''
# Check geometry
if not cmds.objExists(geometry):
om.MGlobal.displayError('Object '+geometry+' does not exist!')
return
# Check transform
if cmds.objectType(geometry) == 'transform':
try: geometry = cmds.listRelatives(geometry,s=True,ni=True,pa=True)[0]
except:
om.MGlobal.displayError('Object %s has no deformable geometry!' % geometry)
return
# Determine skinCluster
skin = mel.eval('findRelatedSkinCluster \"%s\"' % geometry)
if not skin:
skin = cmds.ls(cmds.listHistory(geometry, pdo=1, gl=1), type='skinCluster')
if skin: skin = skin[0]
if not skin: skin = None
# Return result
return skin