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


Python cmds.objectType方法代碼示例

本文整理匯總了Python中maya.cmds.objectType方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.objectType方法的具體用法?Python cmds.objectType怎麽用?Python cmds.objectType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.objectType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: dpLoadBSNode

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def dpLoadBSNode(self, *args):
        """ Load selected object as blendShapeNode
        """
        selectedList = cmds.ls(selection=True)
        if selectedList:
            if cmds.objectType(selectedList[0]) == "blendShape":
                cmds.textField(self.bsNodeTextField, edit=True, text=selectedList[0])
                self.dpLoadBSTgtList(selectedList[0])
                self.bsNode = selectedList[0]
            elif cmds.objectType(selectedList[0]) == "transform":
                meshList = cmds.listRelatives(selectedList[0], children=True, shapes=True, noIntermediate=True, type="mesh")
                if meshList:
                    bsNodeList = cmds.listConnections(meshList[0], type="blendShape")
                    if bsNodeList:
                        self.dpLoadBSTgtList(bsNodeList[0])
                        self.bsNode = bsNodeList[0]
                    else:
                        mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
                else:
                    mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
            else:
                mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";")
        else:
            mel.eval("warning \""+self.langDic[self.langName]["e018_selectBlendShape"]+"\";") 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:26,代碼來源:dpFacialControl.py

示例2: dpCheckSkinCluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:19,代碼來源:dpCopySkin.py

示例3: dpCheckGeometry

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [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

示例4: loadGeo

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [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

示例5: dpCheckGeometry

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:32,代碼來源:dpTargetMirror.py

示例6: dpLoadBSTgtList

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def dpLoadBSTgtList(self, bsNodeName, *args):
        """ Add target list found in the blendShape node to target textScroll list
        """
        if cmds.objExists(bsNodeName):
            if cmds.objectType(bsNodeName) == "blendShape":
                tgtList = cmds.blendShape(bsNodeName, query=True, target=True)
                if tgtList:
                    cmds.textScrollList(self.bsTargetScrollList, edit=True, removeAll=True)
                    cmds.textScrollList(self.bsTargetScrollList, edit=True, append=tgtList)
                    cmds.textField(self.bsNodeTextField, edit=True, text=bsNodeName)
                    self.bsNode = bsNodeName 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:13,代碼來源:dpFacialControl.py

示例7: dpCreateRemapNode

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def dpCreateRemapNode(self, fromNode, fromAttr, toNodeBaseName, toNode, toAttr, number, sizeFactor, oMin=0, oMax=1, iMin=0, iMax=1, *args):
        """ Creates the nodes to remap values and connect it to final output (toNode) item.
        """
        fromNodeName = utils.extractSuffix(fromNode)
        remap = cmds.createNode("remapValue", name=fromNodeName+"_"+fromAttr+"_"+str(number).zfill(2)+"_"+toAttr.upper()+"_RmV")
        outMaxAttr = toNodeBaseName+"_"+str(number).zfill(2)+"_"+toAttr.upper()
        if "t" in toAttr:
            if not cmds.objExists(fromNode+".sizeFactor"):
                cmds.addAttr(fromNode, longName="sizeFactor", attributeType="float", defaultValue=sizeFactor, keyable=False)
            cmds.addAttr(fromNode, longName=outMaxAttr, attributeType="float", defaultValue=oMax, keyable=False)
            md = cmds.createNode("multiplyDivide", name=fromNodeName+"_"+fromAttr+"_"+str(number).zfill(2)+"_"+toAttr.upper()+"_SizeFactor_MD")
            cmds.connectAttr(fromNode+"."+outMaxAttr, md+".input1X", force=True)
            cmds.connectAttr(fromNode+".sizeFactor", md+".input2X", force=True)
            cmds.connectAttr(md+".outputX", remap+".outputMax", force=True)
        else:
            cmds.addAttr(fromNode, longName=outMaxAttr, attributeType="float", defaultValue=oMax, keyable=False)
            cmds.connectAttr(fromNode+"."+outMaxAttr, remap+".outputMax", force=True)
        cmds.setAttr(remap+".inputMin", iMin)
        cmds.setAttr(remap+".inputMax", iMax)
        cmds.setAttr(remap+".outputMin", oMin)
        cmds.connectAttr(fromNode+"."+fromAttr, remap+".inputValue", force=True)
        # check if there's an input connection and create a plusMinusAverage if we don't have one to connect in:
        connectedList = cmds.listConnections(toNode+"."+toAttr, destination=False, source=True, plugs=False)
        if connectedList:
            if cmds.objectType(connectedList[0]) == "plusMinusAverage":
                inputList = cmds.listConnections(connectedList[0]+".input1D", destination=False, source=True, plugs=False)
                cmds.connectAttr(remap+".outValue", connectedList[0]+".input1D["+str(len(inputList))+"]", force=True)
            else:
                if cmds.objectType(connectedList[0]) == "unitConversion":
                    connectedAttr = cmds.listConnections(connectedList[0]+".input", destination=False, source=True, plugs=True)[0]
                else:
                    connectedAttr = cmds.listConnections(toNode+"."+toAttr, destination=False, source=True, plugs=True)[0]
                pma = cmds.createNode("plusMinusAverage", name=toNode+"_"+toAttr.upper()+"_PMA")
                cmds.connectAttr(connectedAttr, pma+".input1D[0]", force=True)
                cmds.connectAttr(remap+".outValue", pma+".input1D[1]", force=True)
                cmds.connectAttr(pma+".output1D", toNode+"."+toAttr, force=True)
                if cmds.objectType(connectedList[0]) == "unitConversion":
                    cmds.delete(connectedList[0])
        else:
            cmds.connectAttr(remap+".outValue", toNode+"."+toAttr, force=True) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:42,代碼來源:dpFacialControl.py

示例8: setNotRenderable

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def setNotRenderable(self, objList, *args):
        """Receive a list of objects, find its shapes if necessary and set all as not renderable.
        """
        # declare a list of attributes for render:
        renderAttrList = ["castsShadows", "receiveShadows", "motionBlur", "primaryVisibility", "smoothShading", "visibleInReflections", "visibleInRefractions", "doubleSided", "miTransparencyCast", "miTransparencyReceive", "miReflectionReceive", "miRefractionReceive", "miFinalGatherCast", "miFinalGatherReceive"]
        shapeTypeList = ['nurbsCurve', 'nurbsSurface', 'mesh', 'subdiv']
        # find all children shapes:
        if objList:
            for obj in objList:
                objType = cmds.objectType(obj)
                # verify if the object is the shape type:
                if objType in shapeTypeList:
                    # set attributes as not renderable:
                    for attr in renderAttrList:
                        try:
                            cmds.setAttr(obj+"."+attr, 0)
                        except:
                            #print "Error: Cannot set not renderable ", attr, "as zero for", obj
                            pass
                # verify if the object is a transform type:
                elif objType == "transform":
                    # find all shapes children of the transform object:
                    shapeList = cmds.listRelatives(obj, shapes=True, children=True)
                    if shapeList:
                        for shape in shapeList:
                            # set attributes as not renderable:
                            for attr in renderAttrList:
                                try:
                                    cmds.setAttr(shape+"."+attr, 0)
                                except:
                                    #print "Error: Cannot set not renderable ", attr, "as zero for", shape
                                    pass 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:34,代碼來源:dpControls.py

示例9: findHistory

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [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 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:15,代碼來源:dpControls.py

示例10: get_spore_setups

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def get_spore_setups(self):
        """ return a dictionary with an entry for each target mesh
        and for each entry a list with all connected spore nodes """

        spore_nodes = cmds.ls(type='sporeNode', l=True)
        targets = collections.defaultdict(list)

        #  TODO - once this can be debugged this would be the way to go
        #  [targets[node_utils.get_connected_in_mesh(node)].append(node) for node in spore_nodes]

        for node in spore_nodes:
            target = node_utils.get_connected_in_mesh(node)
            if target:
                targets[target].append(node)

            else: # May help to debbug a situation wherfe target is sometime None
                target = cmds.getConnection('{}.inMesh'.format(node))
                target_shape = cmds.listRelatives(cmds.ls(target), s=True, f=True)

                if len(target_shape) == 1:
                    obj_type = cmds.objectType(target_shape[0])
                    self.logger.warning(
                        'Getting target mesh failed but spore has been able '
                        'to use fallback. target: {}, shape: {}, type: '
                        '{}'.format(target, target_shape[0], obj_type))
                    targets[target_shape] = node
                else:
                    obj_type = [cmds.objectType(s) for s in target_shape]
                    raise RuntimeError(
                        'Could not get target mesh and spore failed to use '
                        'fallback. target {}, shapes {}, types: {}'.format(
                            target, target_shape, obj_type)
                    )

        return targets 
開發者ID:wiremas,項目名稱:spore,代碼行數:37,代碼來源:manager.py

示例11: BT_Setup

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def BT_Setup(set = None):
    
    if not set:
        return False

    transforms = cmds.listConnections(set +'.dagSetMembers')
    if not transforms:
        return False

    if not cmds.attributeQuery('Blend_Node', n = set, ex = True):
        cmds.addAttr(set, ln = 'Blend_Node', k = False, h = True, dt = 'string')
    else:
        return False

    btNode = cmds.createNode("BlendTransforms")
    cmds.setAttr(set +'.Blend_Node', btNode, type = "string")

    for i in range(0, len(transforms)):
        baseMatrix = cmds.xform(transforms[i], q = True, m = True)
        baseScale = cmds.getAttr(transforms[i] +'.scale')[0]
        baseRotOffset = [0.0, 0.0, 0.0]

        if cmds.objectType(transforms[i], isType = 'joint'):
            baseRotOffset = cmds.getAttr(transforms[i] +'.jointOrient')[0]

        btAttr = 'transforms[' +str(i) +'].baseMatrix'
        btScaleAttr = 'transforms[' +str(i) +'].baseScale'
        btRotOffsetAttr = 'transforms[' +str(i) +'].baseRotOffset'

        BT_MatrixValuesToNode(values = baseMatrix, node = btNode, attr = btAttr)
        BT_Double3ValuesToNode(values = baseScale, node = btNode, attr = btScaleAttr)
        BT_Double3ValuesToNode(values = baseRotOffset, node = btNode, attr = btRotOffsetAttr)
        BT_ConnectOutputs(index = i, node = btNode, transform = transforms[i])

    return True 
開發者ID:duncanskertchly,項目名稱:BlendTransforms,代碼行數:37,代碼來源:BlendTransforms.py

示例12: findRelatedSkinCluster

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [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

#---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:35,代碼來源:utils.py

示例13: createPipe

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def createPipe(self, spans):
        # We set the transform and shape to the class variables
        self.transform, self.shape = cmds.polyPipe(subdivisionsAxis=spans)

        # I didn't like having to find the constructor from the extrude node
        # Lets just find it now and save it to the class because it won't change
        for node in cmds.listConnections('%s.inMesh' % self.transform):
            if cmds.objectType(node) == 'polyPipe':
                self.constructor = node
                break 
開發者ID:dgovil,項目名稱:PythonForMayaSamples,代碼行數:12,代碼來源:gears2.py

示例14: get_shape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def get_shape(node, intermediate=False):
    """Get the shape node of a tranform

    This is useful if you don't want to have to check if a node is a shape node
    or transform.  You can pass in a shape node or transform and the function
    will return the shape node.

    :param node:  node The name of the node.
    :param intermediate:  intermediate True to get the intermediate shape
    :return: The name of the shape node.
    """
    if cmds.objectType(node, isAType="transform"):
        shapes = cmds.listRelatives(node, shapes=True, path=True)
        if not shapes:
            shapes = []
        for shape in shapes:
            is_intermediate = cmds.getAttr("{}.intermediateObject".format(shape))
            if (
                intermediate
                and is_intermediate
                and cmds.listConnections(shape, source=False)
            ):
                return shape
            elif not intermediate and not is_intermediate:
                return shape
        if shapes:
            return shapes[0]
    elif cmds.nodeType(node) in ["mesh", "nurbsCurve", "nurbsSurface"]:
        is_intermediate = cmds.getAttr("{}.intermediateObject".format(node))
        if is_intermediate and not intermediate:
            node = cmds.listRelatives(node, parent=True, path=True)[0]
            return get_shape(node)
        else:
            return node
    return None 
開發者ID:chadmv,項目名稱:cmt,代碼行數:37,代碼來源:shortcuts.py

示例15: colorShape

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import objectType [as 別名]
def colorShape(self, objList, color, rgb=False, *args):
        """ Create a color override for all shapes from the objList.
        """
        if rgb:
            pass
        elif (dic_colors.has_key(color)):
            iColorIdx = dic_colors[color]
        else:
            iColorIdx = color

        # find shapes and apply the color override:
        shapeTypeList = ['nurbsCurve', 'nurbsSurface', 'mesh', 'subdiv']
        if objList:
            for objName in objList:
                objType = cmds.objectType(objName)
                # verify if the object is the shape type:
                if objType in shapeTypeList:
                    # set override as enable:
                    cmds.setAttr(objName+".overrideEnabled", 1)
                    # set color override:
                    if rgb:
                        cmds.setAttr(objName+".overrideRGBColors", 1)
                        cmds.setAttr(objName+".overrideColorR", color[0])
                        cmds.setAttr(objName+".overrideColorG", color[1])
                        cmds.setAttr(objName+".overrideColorB", color[2])
                    else:
                        cmds.setAttr(objName+".overrideRGBColors", 0)
                        cmds.setAttr(objName+".overrideColor", iColorIdx)
                # verify if the object is a transform type:
                elif objType == "transform":
                    # find all shapes children of the transform object:
                    shapeList = cmds.listRelatives(objName, shapes=True, children=True, fullPath=True)
                    if shapeList:
                        for shape in shapeList:
                            # set override as enable:
                            cmds.setAttr(shape+".overrideEnabled", 1)
                            # set color override:
                            if rgb:
                                cmds.setAttr(shape+".overrideRGBColors", 1)
                                cmds.setAttr(shape+".overrideColorR", color[0])
                                cmds.setAttr(shape+".overrideColorG", color[1])
                                cmds.setAttr(shape+".overrideColorB", color[2])
                            else:
                                cmds.setAttr(shape+".overrideRGBColors", 0)
                                cmds.setAttr(shape+".overrideColor", iColorIdx) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:47,代碼來源:dpControls.py


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