本文整理汇总了Python中maya.cmds.objExists方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.objExists方法的具体用法?Python cmds.objExists怎么用?Python cmds.objExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.objExists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: dpSelectAllCtrls
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def dpSelectAllCtrls(self, allGrpNode, *args):
""" Select all controls using All_Grp.
"""
ctrlsToSelectList = []
if cmds.objExists(allGrpNode+"."+self.ctrlsAttr):
ctrlsAttr = cmds.getAttr(allGrpNode+"."+self.ctrlsAttr)
if ctrlsAttr:
currentNamespace = ""
if ":" in allGrpNode:
currentNamespace = allGrpNode[:allGrpNode.find(":")]
ctrlsList = ctrlsAttr.split(";")
if ctrlsList:
for ctrlName in ctrlsList:
if ctrlName:
if currentNamespace:
ctrlsToSelectList.append(currentNamespace+":"+ctrlName)
else:
ctrlsToSelectList.append(ctrlName)
cmds.select(ctrlsToSelectList)
print self.langDic[self.langName]["m169_selectedCtrls"]+str(ctrlsToSelectList)
else:
mel.eval("warning \""+self.langDic[self.langName]["e019_notFoundAllGrp"]+"\";")
示例2: unique
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def unique(name):
assert isinstance(name, basestring), "`name` must be string"
while cmds.objExists(name):
matches = re.findall(r"\d+$", name)
if matches:
match = matches[-1]
name = name.rstrip(match)
number = int(match) + 1
else:
number = 1
name = name + str(number)
return name
示例3: lock
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def lock():
"""Lock scene
Add an invisible node to your Maya scene with the name of the
current file, indicating that this file is "locked" and cannot
be modified any further.
"""
if not cmds.objExists("lock"):
with lib.maintained_selection():
cmds.createNode("objectSet", name="lock")
cmds.addAttr("lock", ln="basename", dataType="string")
# Permanently hide from outliner
cmds.setAttr("lock.verticesOnlySet", True)
fname = cmds.file(query=True, sceneName=True)
basename = os.path.basename(fname)
cmds.setAttr("lock.basename", basename, type="string")
示例4: dpLoadJointNode
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def dpLoadJointNode(self, itemList, *args):
""" Load the respective items to build the joint target list (offset group node).
"""
leftPrefix = self.langDic[self.langName]["p002_left"]+"_"
rightPrefix = self.langDic[self.langName]["p003_right"]+"_"
offsetSuffix = "_Ctrl_Offset_Grp"
for item in itemList:
centerName = item+offsetSuffix
leftName = leftPrefix+item+offsetSuffix
rightName = rightPrefix+item+offsetSuffix
if cmds.objExists(centerName):
self.dpLoadJointTgtList(centerName)
if cmds.objExists(leftName):
self.dpLoadJointTgtList(leftName)
if cmds.objExists(rightName):
self.dpLoadJointTgtList(rightName)
示例5: dpMain
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def dpMain(self, *args):
""" Main function.
Check existen nodes and call the scripted function.
"""
callAction = True
if not cmds.objExists(self.spineChestACtrl):
callAction = False
if not cmds.objExists(self.globalCtrl):
callAction = False
if not cmds.objExists(self.rootCtrl):
callAction = False
if not cmds.objExists(self.spineHipsBCtrl):
callAction = False
if not cmds.objExists(self.headCtrl):
callAction = False
if callAction:
self.dpDoAddHandFollow()
示例6: dpCheckGeometry
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def dpCheckGeometry(self, item, *args):
isGeometry = False
if item:
if cmds.objExists(item):
childList = cmds.listRelatives(item, children=True)
if childList:
self.itemType = cmds.objectType(childList[0])
if self.itemType == "mesh" or self.itemType == "nurbsSurface":
if self.itemType == "mesh":
self.meshNode = childList[0]
isGeometry = True
else:
mel.eval("warning \""+item+" is not a geometry.\";")
else:
mel.eval("warning \"Select the transform node instead of "+item+" shape, please.\";")
else:
mel.eval("warning \""+item+" does not exists, maybe it was deleted, sorry.\";")
else:
mel.eval("warning \"Not found "+item+"\";")
return isGeometry
示例7: dpMain
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def dpMain(self, *args):
""" Main function.
Check existen nodes and call the scripted function.
# nodeList[0] = Root_Ctrl
# nodeList[1] = Grand Father transform from selected item
# nodeList[2] = Selected item (control)
"""
# declaring nodeList to create the isolate setup:
nodeList = [self.rootCtrl, self.grandFatherItem, self.selItem]
if len(nodeList) == 3:
for nodeName in nodeList:
if not cmds.objExists(nodeName):
print self.langDic[self.langName]['e004_objNotExist'], nodeName
return
# call scripted function
self.dpIsolate(self.isolateName, nodeList)
示例8: verifyGuideModuleIntegrity
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def verifyGuideModuleIntegrity(self, *args):
""" This function verify the integrity of the current module.
Returns True if Ok and False if Fail.
"""
# conditionals to be elegible as a rigged guide module:
if cmds.objExists(self.moduleGrp):
if cmds.objExists(self.moduleGrp+'.guideBase'):
if cmds.getAttr(self.moduleGrp+'.guideBase') == 1:
return True
else:
try:
self.deleteModule()
mel.eval('warning \"'+ self.langDic[self.langName]['e000_GuideNotFound'] +' - '+ self.moduleGrp +'\";')
except:
pass
return False
示例9: loadGeo
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def loadGeo(self, *args):
""" Loads the selected node to geoTextField in selectedModuleLayout.
"""
isGeometry = False
selList = cmds.ls(selection=True)
if selList:
if cmds.objExists(selList[0]):
childList = cmds.listRelatives(selList[0], children=True, allDescendents=True)
if childList:
for item in childList:
itemType = cmds.objectType(item)
if itemType == "mesh" or itemType == "nurbsSurface":
isGeometry = True
if isGeometry:
cmds.textField(self.geoTF, edit=True, text=selList[0])
cmds.setAttr(self.moduleGrp+".geo", selList[0], type='string')
示例10: findModuleLastNumber
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def findModuleLastNumber(className, typeName):
""" Find the last used number of this type of module.
Return its highest number.
"""
# work with rigged modules in the scene:
numberList = []
guideTypeCount = 0
# list all transforms and find the existing value in them names:
transformList = cmds.ls(selection=False, transforms=True)
for transform in transformList:
if cmds.objExists(transform+"."+typeName):
if cmds.getAttr(transform+"."+typeName) == className:
numberList.append(className)
# try check if there is a masterGrp and get its counter:
if cmds.objExists(transform+".masterGrp") and cmds.getAttr(transform+".masterGrp") == 1:
guideTypeCount = cmds.getAttr(transform+'.dp'+className+'Count')
if(guideTypeCount > len(numberList)):
return guideTypeCount
else:
return len(numberList)
示例11: clearNodeGrp
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def clearNodeGrp(nodeGrpName='dpAR_GuideMirror_Grp', attrFind='guideBaseMirror', unparent=False):
""" Check if there is any node with the attribute attrFind in the nodeGrpName and then unparent its children and delete it.
"""
if cmds.objExists(nodeGrpName):
foundChildrenList = []
childrenList = cmds.listRelatives(nodeGrpName, children=True, type="transform")
if childrenList:
for child in childrenList:
if cmds.objExists(child+"."+attrFind) and cmds.getAttr(child+"."+attrFind) == 1:
foundChildrenList.append(child)
if len(foundChildrenList) != 0:
if unparent:
for item in foundChildrenList:
cmds.parent(item, world=True)
cmds.delete(nodeGrpName)
else:
cmds.delete(nodeGrpName)
示例12: mirroredGuideFather
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def mirroredGuideFather(nodeName):
""" This function verify if there is a mirrored guide as a father of the passed nodeName.
Returns the mirrored guide father name if true.
"""
parentList = cmds.listRelatives(nodeName, parent=True, type='transform')
if parentList:
nextLoop = True
while nextLoop:
if cmds.objExists(parentList[0]+".guideBase") and cmds.getAttr(parentList[0]+".guideBase") == 1 and cmds.getAttr(parentList[0]+".mirrorEnable") == 1 and cmds.getAttr(parentList[0]+".mirrorAxis") != "off":
return parentList[0]
nextLoop = False
else:
parentList = cmds.listRelatives(parentList[0], parent=True, type='transform')
if parentList:
nextLoop = True
else:
nextLoop = False
示例13: zeroOutJoints
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def zeroOutJoints(jntList=None):
""" Duplicate the joints, parent as zeroOut.
Returns the father joints (zeroOuted).
Deprecated = using zeroOut function insted.
"""
resultList = []
zeroOutJntSuffix = "_Jzt"
if jntList:
for jnt in jntList:
if cmds.objExists(jnt):
jxtName = jnt.replace("_Jnt", "").replace("_Jxt", "")
if not zeroOutJntSuffix in jxtName:
jxtName += zeroOutJntSuffix
dup = cmds.duplicate(jnt, name=jxtName)[0]
deleteChildren(dup)
clearDpArAttr([dup])
cmds.parent(jnt, dup)
resultList.append(dup)
return resultList
示例14: item_clicked
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def item_clicked(self, widget, event):
item_name = widget.long_name
item_state = widget.is_selected
if cmds.objExists(item_name):
is_modified = event.modifiers() == Qt.ControlModifier
if not is_modified:
cmds.select(clear=True)
for geo_item, spore_items in self.wdg_tree.iteritems():
for spore_item in spore_items:
if is_modified \
and spore_item.is_selected:
cmds.select(spore_item.long_name, add=True)
else:
spore_item.deselect()
cmds.select(spore_item.long_name, deselect=True)
widget.set_select(item_state)
if not is_modified:
cmds.select(item_name)
else:
self.refresh_spore()
示例15: name_changed
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import objExists [as 别名]
def name_changed(self, widget, name):
""" triggered by one of the spore widgets when the user
requests a name change
:param widget: the source of the signal
:param name: the new name """
node_name = widget.long_name
if cmds.objExists(node_name):
if re.match('^[A-Za-z0-9_-]*$', name) and not name[0].isdigit():
# transform = cmds.listRelatives(node_name, p=True, f=True)[0]
instancer = node_utils.get_instancer(node_name)
cmds.rename(instancer, '{}Instancer'.format(name))
cmds.rename(node_name, '{}Shape'.format(name))
# cmds.rename(transform, name)
else:
self.io.set_message('Invalid Name: Use only A-Z, a-z, 0-9, -, _', 2)
return
self.refresh_spore()