当前位置: 首页>>代码示例>>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;未经允许,请勿转载。