當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.objExists方法代碼示例

本文整理匯總了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"]+"\";") 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:24,代碼來源:dpSelectAllControls.py

示例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 
開發者ID:getavalon,項目名稱:core,代碼行數:18,代碼來源:util.py

示例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") 
開發者ID:getavalon,項目名稱:core,代碼行數:22,代碼來源:pipeline.py

示例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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:18,代碼來源:dpFacialControl.py

示例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() 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:dpAddHandFollow.py

示例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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:22,代碼來源:dpRivet.py

示例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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:18,代碼來源:dpIsolate.py

示例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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:18,代碼來源:dpBaseClass.py

示例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') 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:18,代碼來源:dpLayoutClass.py

示例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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:22,代碼來源:dpUtils.py

示例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) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:dpUtils.py

示例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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:dpUtils.py

示例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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:21,代碼來源:dpUtils.py

示例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() 
開發者ID:wiremas,項目名稱:spore,代碼行數:27,代碼來源:manager.py

示例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() 
開發者ID:wiremas,項目名稱:spore,代碼行數:22,代碼來源:manager.py


注:本文中的maya.cmds.objExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。