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


Python cmds.nodeType方法代碼示例

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


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

示例1: shape_from_element

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def shape_from_element(element):
    """Return shape of given 'element'

    Supports components, meshes, and surfaces

    """

    try:
        # Get either shape or transform, based on element-type
        node = cmds.ls(element, objectsOnly=True)[0]
    except:
        cmds.warning("Could not find node in %s" % element)
        return None

    if cmds.nodeType(node) == 'transform':
        try:
            return cmds.listRelatives(node, shapes=True)[0]
        except:
            cmds.warning("Could not find shape in %s" % element)
            return None

    else:
        return node 
開發者ID:getavalon,項目名稱:core,代碼行數:25,代碼來源:util.py

示例2: convertToBezierCurve

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def convertToBezierCurve(curve):
    """
    Check if the parsed curve is a bezier curve, if this is not the case
    convert the curve to a bezier curve.
    
    :param str curve: Name of curve
    """
    # get shape
    curveShape = cmds.listRelatives(curve, s=True)[0]

    # convert to bezier curve
    if cmds.nodeType(curveShape) == "bezierCurve":
        return
        
    cmds.select(curve)
    cmds.nurbsCurveToBezier()


# ---------------------------------------------------------------------------- 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:21,代碼來源:curve.py

示例3: reset_actor

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def reset_actor():
    from . import sisidebar_sub
    sel = cmds.ls(sl=True, l=True)
    joints = cmds.ls(sl=True, l=True, type='joint')
    if not joints:
        joints = []
    for s in sel:
        if cmds.nodeType(s) == 'KTG_ModelRoot':
            child_joints = cmds.ls(cmds.listRelatives(s, ad=True, f=True), l=True, type='joint')
            if child_joints:
                joints += child_joints
    if not sel:
        joints = cmds.ls(l=True, type='joint')
    for j in joints:
        con_info = cmds.connectionInfo(j+'.bindPose', dfs=True)
        if not con_info:
            continue
        con_info = con_info[0]
        bind_info = con_info.replace('world', 'xform')
        pose = cmds.getAttr(bind_info)
        cmds.xform(j, m=pose)
    sisidebar_sub.get_matrix() 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:24,代碼來源:transform.py

示例4: add_to_set_members

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def add_to_set_members():
    selection = cmds.ls(sl=True)
    
    if selection:
        setCount = 0
        for node in selection:
            if cmds.nodeType(node) != 'objectSet':
                continue
            for sel in selection:
                if sel == node:
                    continue
                try:
                    cmds.sets(sel, add=node)
                except Exception as e:
                    print e.message
            setCount += 1
        if setCount == 0:
            cmds.confirmDialog( title='Error',message='Please select set_node')

#選択セットのノード、コンポーネントを削除 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:22,代碼來源:sets.py

示例5: remove_set_members

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def remove_set_members():
    selection = cmds.ls(sl=True)
    if selection:
        setCount = 0
        for node in selection:
            if cmds.nodeType(node) != 'objectSet':
                continue
            setMembers = cmds.sets(node, int=node)
            for removeNode in selection:
                if removeNode == node:
                    continue
                try:
                    print 'Remove from set :', node, ': Object :', removeNode
                    cmds.sets(removeNode, rm=node)
                except:
                    pass
            setCount += 1
        if setCount == 0:
            cmds.confirmDialog( title='Error',message='Please select set_node') 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:21,代碼來源:sets.py

示例6: blendShapeSampling

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def blendShapeSampling(node, interval=1):
    """
    Args:
      node (str)
      interval (int)
    
    Returns:
      int
    """
    assert cmds.nodeType(node) == 'blendShape', \
        "node must be a blendShape type"
    start = cmds.currentTime(q=1)
    
    attrs = cmds.listAttr('%s.weight' % node, m=1)
    attrData = {node: [[attr, 0.0, 1.0] for attr in attrs]}
    
    currTime = attrsSampling(attrData, interval)

    end = currTime-1
    utils.trimTimeRange(start, end)
    cmds.currentTime(start)

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

示例7: getSkinCluster

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

示例8: getInfluenceIcon

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def getInfluenceIcon(self):
        """
        Get the influence icon based on the node type of the influence. If
        the node type is not present in the INFLUENCE_ICONS variable the
        icon will be defaulted to a transform.

        :return: Icon
        :rtype: QIcon
        """
        # get influence node type
        nodeType = cmds.nodeType(self.influence)

        # get icon path
        path = INFLUENCE_ICONS.get(nodeType, ":/out_transform.png")
        return Qt.QIcon(path)

    # ------------------------------------------------------------------------ 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:19,代碼來源:ui.py

示例9: convertSkelSettingsToNN

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def convertSkelSettingsToNN(delete=1):
        orig = 'SkeletonSettings_Cache'
        if cmds.objExists(orig):
            if cmds.nodeType(orig) == 'unknown':
                new = cmds.createNode('network')
                for att in cmds.listAttr(orig):
                    if not cmds.attributeQuery(att, node=new, exists=1):
                        typ = cmds.attributeQuery(att, node=orig, at=1)
                        if typ == 'typed':
                            cmds.addAttr(new, longName=att, dt='string')
                            if cmds.getAttr(orig + '.' + att):
                                cmds.setAttr(new + '.' + att, cmds.getAttr(orig + '.' + att), type='string')
                        elif typ == 'enum':
                            cmds.addAttr(new, longName=att, at='enum', enumName=cmds.attributeQuery(att, node=orig, listEnum=1)[0])
                cmds.delete(orig)
                cmds.rename(new, 'SkeletonSettings_Cache') 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:18,代碼來源:uExport.py

示例10: get_joint_data

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def get_joint_data(node):
    """Get the serializable data of a node.

    :param node: Joint or transform name.
    :return: Data dictionary.
    """
    node_type = cmds.nodeType(node)
    shapes = cmds.listRelatives(node, children=True, shapes=True)
    if node_type not in ["joint", "transform"] or (shapes and node_type == "transform"):
        # Skip nodes that are not joints or transforms or if there are shapes below.
        return None

    parent = cmds.listRelatives(node, parent=True)
    parent = parent[0] if parent else None
    joint_data = {"nodeType": node_type, "name": node, "parent": parent}
    for attr in ATTRIBUTES:
        attribute = "{}.{}".format(node, attr)
        if not cmds.objExists(attribute):
            continue
        value = cmds.getAttr(attribute)
        if isinstance(value, list):
            value = list(value[0])
        joint_data[attr] = value
    return joint_data 
開發者ID:chadmv,項目名稱:cmt,代碼行數:26,代碼來源:skeleton.py

示例11: create

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def create(data_list):
    """Create the transform hierarchy.

    :param data_list: The list of transform/joint data generated from dumps.
    """
    for data in data_list:
        node = data["name"]
        if not cmds.objExists(node):
            node = cmds.createNode(data["nodeType"], name=node)
        parent = data["parent"]
        if parent and cmds.objExists(parent):
            cmds.parent(node, parent)
        for attr in ATTRIBUTES:
            attribute = "{}.{}".format(node, attr)
            if not cmds.objExists(attribute):
                continue
            value = data[attr]
            if isinstance(value, string_types):
                cmds.setAttr(attribute, value, type="string")
            elif isinstance(value, list):
                cmds.setAttr(attribute, *value)
            else:
                cmds.setAttr(attribute, value) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:25,代碼來源:skeleton.py

示例12: _set_from_curve

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def _set_from_curve(self, transform):
        """Store the parameters from an existing curve in the CurveShape object.

        :param transform: Transform
        """
        shape = shortcuts.get_shape(transform)
        if shape and cmds.nodeType(shape) == "nurbsCurve":
            create_attr = "{}.create".format(shape)
            connection = cmds.listConnections(create_attr, plugs=True, d=False)
            if connection:
                cmds.disconnectAttr(connection[0], create_attr)
            self.transform = transform
            self.cvs = cmds.getAttr("{}.cv[*]".format(shape))
            self.degree = cmds.getAttr("{}.degree".format(shape))
            self.form = cmds.getAttr("{}.form".format(shape))
            self.knots = get_knots(shape)
            if cmds.getAttr("{}.overrideEnabled".format(shape)):
                if cmds.getAttr("{}.overrideRGBColors".format(shape)):
                    self.color = cmds.getAttr("{}.overrideColorRGB".format(shape))[0]
                else:
                    self.color = cmds.getAttr("{}.overrideColor".format(shape))
            else:
                self.color = None
            if connection:
                cmds.connectAttr(connection[0], create_attr) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:27,代碼來源:control.py

示例13: input_transform

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def input_transform(self, i):
        """Get the input transform at index

        :param i: Index
        :return: The transform driving the input at index i
        """
        input_count = cmds.getAttr("{}.inputQuatCount".format(self.name))
        if i >= input_count:
            raise RuntimeError("Invalid input index")
        # Traverse connections to the transform
        # inputQuat <- decomposeMatrix <- transform
        connection = cmds.listConnections(
            "{}.inputQuat[{}]".format(self.name, i), d=False
        )

        if not connection or cmds.nodeType(connection[0]) != "decomposeMatrix":
            return None
        connection = cmds.listConnections(
            "{}.inputMatrix".format(connection[0]), d=False
        )
        return connection[0] if connection else None 
開發者ID:chadmv,項目名稱:cmt,代碼行數:23,代碼來源:rbf.py

示例14: get_blendshape_node

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

示例15: node_attributes

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import nodeType [as 別名]
def node_attributes(node):
    """
    Get Maya node attributes
    """
    attributes = cmds.listAttr(node)
    attr = {}
    attr["node_name"] = node
    attr["node_type"] = cmds.nodeType(node)
    for attribute in attributes:
        if "." in attribute:
            continue
        try:
            val = cmds.getAttr(node + "." + attribute)
        except RuntimeError:
            continue
        attr[attribute] = val
    return attr 
開發者ID:ababak,項目名稱:maya2katana,代碼行數:19,代碼來源:utils.py


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