本文整理汇总了Python中maya.cmds.listHistory方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.listHistory方法的具体用法?Python cmds.listHistory怎么用?Python cmds.listHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.listHistory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dpCheckSkinCluster
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def dpCheckSkinCluster(self, shapeList, *args):
""" Verify if there's a skinCluster node in the list of history of the shape.
Return True if yes.
Return False if no.
Return -1 if there's another node with the same name.
"""
for shapeNode in shapeList:
if not shapeNode.endswith("Orig"):
try:
histList = cmds.listHistory(shapeNode)
if histList:
for histItem in histList:
if cmds.objectType(histItem) == "skinCluster":
return True
except:
return -1
return False
示例2: findRelatedDeltaMush
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def findRelatedDeltaMush(geometry):
"""
Return the delta mush deformer attached to the specified geometry
Args:
geometry (str): Geometry object/transform to query
Returns:
str
"""
# Check geometry
if not cmds.objExists(geometry):
raise Exception('Object '+geometry+' does not exist!')
hist = cmds.listHistory(geometry, pdo=1, gl=1)
try:
if mayaVersion() >= 2016:
return cmds.ls(hist, type=["deltaMush", "wbDeltaMush"])[0]
else:
return cmds.ls(hist, type="wbDeltaMush")[0]
except:
return None
#----------------------------------------------------------------------
示例3: getSkinCluster
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def getSkinCluster(mesh):
"""
Loop over an objects history and see if a skinCluster node is part of the
history.
:param str mesh:
:return: skinCluster that is attached to the parsed mesh
:rtype: str or None
"""
skinClusters = [
h
for h in cmds.listHistory(mesh) or []
if cmds.nodeType(h) == "skinCluster"
]
if skinClusters:
return skinClusters[0]
示例4: get_blendshape_node
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def get_blendshape_node(geometry):
"""Get the first blendshape node upstream from the given geometry.
:param geometry: Name of the geometry
:return: The blendShape node name
"""
geometry = shortcuts.get_shape(geometry)
history = cmds.listHistory(geometry, il=2, pdo=False) or []
blendshapes = [
x
for x in history
if cmds.nodeType(x) == "blendShape"
and cmds.blendShape(x, q=True, g=True)[0] == geometry
]
if blendshapes:
return blendshapes[0]
else:
return None
示例5: getSkinCluster
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def getSkinCluster(mesh):
'''
Return the first skinCluster affecting this mesh.
'''
if mc.nodeType(mesh) in ('mesh','nurbsSurface','nurbsCurve'):
shapes = [mesh]
else:
shapes = mc.listRelatives(mesh, shapes=True, path=True)
for shape in shapes:
history = mc.listHistory(shape, groupLevels=True, pruneDagObjects=True)
if not history:
continue
skins = mc.ls(history, type='skinCluster')
if skins:
return skins[0]
return None
示例6: dpCheckGeometry
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def dpCheckGeometry(self, item, *args):
isGeometry = False
if item:
if cmds.objExists(item):
childList = cmds.listRelatives(item, children=True)
if childList:
try:
itemType = cmds.objectType(childList[0])
if itemType == "mesh" or itemType == "nurbsSurface" or itemType == "subdiv":
if cmds.checkBox(self.checkHistoryCB, query=True, value=True):
historyList = cmds.listHistory(childList[0])
if len(historyList) > 1:
dialogReturn = cmds.confirmDialog(title=self.langDic[self.langName]["i159_historyFound"], message=self.langDic[self.langName]["i160_historyDesc"]+"\n\n"+item+"\n\n"+self.langDic[self.langName]["i161_historyMessage"], button=['Yes','No'], defaultButton='Yes', cancelButton='No', dismissString='No')
if dialogReturn == "Yes":
isGeometry = True
else:
isGeometry = True
else:
isGeometry = True
else:
mel.eval("warning \""+item+" "+self.langDic[self.langName]["i058_notGeo"]+"\";")
except:
mel.eval("warning \""+self.langDic[self.langName]["i163_sameName"]+" "+item+"\";")
else:
mel.eval("warning \""+self.langDic[self.langName]["i059_selTransform"]+" "+item+" "+self.langDic[self.langName]["i060_shapePlease"]+"\";")
else:
mel.eval("warning \""+item+" "+self.langDic[self.langName]["i061_notExists"]+"\";")
else:
mel.eval("warning \""+self.langDic[self.langName]["i062_notFound"]+" "+item+"\";")
return isGeometry
示例7: findHistory
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def findHistory(self, objList, historyName, *args):
"""Search and return the especific history of the listed objects.
"""
if objList:
foundHistoryList = []
for objName in objList:
# find historyName in the object's history:
histList = cmds.listHistory(objName)
for hist in histList:
histType = cmds.objectType(hist)
if histType == historyName:
foundHistoryList.append(hist)
return foundHistoryList
示例8: store_blend_shape
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def store_blend_shape(mesh):
shapes = cmds.listRelatives(mesh, s=True, f=True)
skin = cmds.ls(cmds.listHistory(shapes), type='skinCluster')
if skin:
connections = cmds.listConnections(skin, s=True, d=False)
else:
connections = cmds.listConnections(shapes, s=True, d=False)
blend_shapes = cmds.ls(connections, l=True, type='blendShape')
bs_dict = {}
if blend_shapes:
for bs in blend_shapes:
shape_target = cmds.ls(cmds.listConnections(bs, s=True, d=False), l=True, type='transform')
bs_dict[bs]=shape_target
return bs_dict
return
示例9: deleteZeroShape
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def deleteZeroShape(node):
meshnode = cmds.listRelatives(node, s=True, pa=True, type='mesh', fullPath=True)
for mesh in meshnode:
triNum = cmds.polyEvaluate(mesh, triangle=True)
historyNode = cmds.listHistory(mesh, f=True)
if len(historyNode) <= 1:
cmds.delete(mesh)
示例10: save_cluster
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def save_cluster(node):
#ノードの中からスキンクラスタを取得してくる#inMesh直上がSkinClusterとは限らないので修正
srcDeformerCluster = cmds.ls(cmds.listHistory(node),type='cluster')
if not srcDeformerCluster:
return#スキンクラスタがなかったら関数抜ける
#スキンクラスタのパラメータ色々を取得しておく
srcDeformerCluster = srcDeformerCluster[0]
attributes = cmds.listAttr(srcDeformerCluster)
weightList = cmds.getAttr(srcDeformerCluster+'.weightList[0]')
envelope = cmds.getAttr(srcDeformerCluster+'.envelope')
clusterMssage = cmds.getAttr(srcDeformerCluster+'.message')
clusterWeight = cmds.getAttr(srcDeformerCluster+'.weightList[0].weights')
示例11: findRelatedSkinCluster
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
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
#----------------------------------------------------------------------
示例12: isBlendshape
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def isBlendshape(self, mesh):
future = cmds.listHistory(mesh, future=1)
isShape = False
for node in future:
if cmds.nodeType(node) == 'blendShape':
return True
return False
示例13: get_skin_clusters
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def get_skin_clusters(nodes):
"""Get the skinClusters attached to the specified node and all nodes in descendents.
:param nodes: List of dag nodes.
@return A list of the skinClusters in the hierarchy of the specified root node.
"""
if isinstance(nodes, string_types):
nodes = [nodes]
all_skins = []
for node in nodes:
relatives = cmds.listRelatives(node, ad=True, path=True) or []
relatives.insert(0, node)
relatives = [shortcuts.get_shape(node) for node in relatives]
for relative in relatives:
history = cmds.listHistory(relative, pruneDagObjects=True, il=2) or []
skins = [x for x in history if cmds.nodeType(x) == "skinCluster"]
if skins:
all_skins.append(skins[0])
return list(set(all_skins))
示例14: main
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
def main():
sel = mc.ls(sl=True)
for each in sel:
shapes = mc.listRelatives(each, shapes=True)
for shape in shapes:
#get skin cluster
history = mc.listHistory(shape, groupLevels=True, pruneDagObjects=True)
skins = mc.ls(history, type='skinCluster')
for skin in skins:
joints = mc.skinCluster(skin, query=True, influence=True)
mc.setAttr(skin+'.envelope', 0)
mc.skinCluster(skin, edit=True, unbindKeepHistory=True)
#delete bindPose
dagPose = mc.dagPose(each, query=True, bindPose=True)
if dagPose:
mc.delete(dagPose)
dagPose = mc.listConnections(skin+'.bindPose', d=False, type='dagPose')
if dagPose:
mc.delete(dagPose)
mc.skinCluster(joints, shape, toSelectedBones=True)
mc.setAttr(skin+'.envelope', 1)
if sel:
mc.select(sel)
示例15: meshesFromHistory
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import listHistory [as 别名]
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