当前位置: 首页>>代码示例>>Python>>正文


Python cmds.createNode方法代码示例

本文整理汇总了Python中maya.cmds.createNode方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.createNode方法的具体用法?Python cmds.createNode怎么用?Python cmds.createNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.createNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: lock

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [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

示例2: maintained_selection

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def maintained_selection():
    """Maintain selection during context

    Example:
        >>> scene = cmds.file(new=True, force=True)
        >>> node = cmds.createNode("transform", name="Test")
        >>> cmds.select("persp")
        >>> with maintained_selection():
        ...     cmds.select("Test", replace=True)
        >>> "Test" in cmds.ls(selection=True)
        False

    """

    previous_selection = cmds.ls(selection=True)
    try:
        yield
    finally:
        if previous_selection:
            cmds.select(previous_selection,
                        replace=True,
                        noExpand=True)
        else:
            cmds.select(clear=True) 
开发者ID:getavalon,项目名称:core,代码行数:26,代码来源:lib.py

示例3: dpIsolate

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def dpIsolate(self, attrName, nodeList, *args):
        """ Function to run isolate setup.
        """
        # get father zero out transform node
        zeroGrp = cmds.listRelatives(nodeList[2], allParents=True, type="transform")[0]
        # create parent constraint
        pConst = cmds.parentConstraint(nodeList[0], nodeList[1], zeroGrp, maintainOffset=True, skipTranslate=["x", "y", "z"])[0]
        # add isolate attribute to selected control
        cmds.addAttr(nodeList[2], longName=attrName, defaultValue=1.0, minValue=0, maxValue=1, keyable=True) 
        # create reverse node
        reverseNode = cmds.createNode('reverse', name=nodeList[2]+"_"+attrName.capitalize()+"_Rev")
        # do isolate connections
        cmds.connectAttr(nodeList[2]+"."+attrName, pConst+"."+nodeList[0]+"W0", force=True)
        cmds.connectAttr(nodeList[2]+"."+attrName, reverseNode+".inputX", force=True)
        cmds.connectAttr(reverseNode+".outputX", pConst+"."+nodeList[1]+"W1", force=True)
        cmds.select(nodeList[2]) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:18,代码来源:dpIsolate.py

示例4: twistBoneMatrix

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def twistBoneMatrix(nodeA, nodeB, twistBoneName, twistBoneMD=None, axis='Z', inverse=True, *args):
    """ Create matrix nodes and quaternion to extract rotate.
        nodeA = father transform node
        nodeB = child transform node
        Returns the final multiplyDivide node created or given.
        Reference:
        https://bindpose.com/maya-matrix-nodes-part-2-node-based-matrix-twist-calculator/
    """
    twistBoneMM = cmds.createNode("multMatrix", name=twistBoneName+"_ExtractAngle_MM")
    twistBoneDM = cmds.createNode("decomposeMatrix", name=twistBoneName+"_ExtractAngle_DM")
    twistBoneQtE = cmds.createNode("quatToEuler", name=twistBoneName+"_ExtractAngle_QtE")
    cmds.connectAttr(nodeB+".worldMatrix[0]", twistBoneMM+".matrixIn[0]", force=True)
    if inverse:
        cmds.connectAttr(nodeA+".worldInverseMatrix[0]", twistBoneMM+".matrixIn[1]", force=True)
    else:
        cmds.connectAttr(nodeA+".worldMatrix[0]", twistBoneMM+".matrixIn[1]", force=True)
    cmds.connectAttr(twistBoneMM+".matrixSum", twistBoneDM+".inputMatrix", force=True)
    cmds.connectAttr(twistBoneDM+".outputQuat.outputQuat"+axis, twistBoneQtE+".inputQuat.inputQuat"+axis, force=True)
    cmds.connectAttr(twistBoneDM+".outputQuat.outputQuatW", twistBoneQtE+".inputQuat.inputQuatW", force=True)
    if twistBoneMD:
        cmds.connectAttr(twistBoneQtE+".outputRotate.outputRotate"+axis, twistBoneMD+".input2"+axis, force=True)
    else:
        twistBoneMD = cmds.createNode("multiplyDivide", name=twistBoneName+"_MD")
        cmds.connectAttr(twistBoneQtE+".outputRotate.outputRotate"+axis, twistBoneMD+".input2"+axis, force=True)
    return twistBoneMD 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:27,代码来源:dpUtils.py

示例5: __normalizeSlideAttributes

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def __normalizeSlideAttributes(self):
        normalized = []
        attributes = [
            "slide_center", 
            "slide_shift", 
            "slide_shift_min", 
            "slide_shift_max"
        ]
        
        # loop attributes
        for attr in attributes:
            mdl = cmds.createNode(
                "multDoubleLinear",
                n="{0}_{1}_norm_mdl".format(self.name, attr)
            )

            cmds.setAttr("{0}.input1".format(mdl), 0.1)
            cmds.connectAttr(
                "{0}.{1}".format(self.slideControl, attr),
                "{0}.input2".format(mdl)
            )

            normalized.append("{0}.output".format(mdl))

        return normalized 
开发者ID:robertjoosten,项目名称:maya-spline-ik,代码行数:27,代码来源:create.py

示例6: from_value

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def from_value(cls, value, base_name):
        """
        Generating a scalar vector from a value

        This function generates a node and a channel used to host the value
        and attach the channel to a NScalar vector class

        Args:

        :value: float,int, the value of the NScalar
        :base_name: str, the name we will use for the node + "_vec", the attribute name will
                        be generated with base_name + "_from_value"
        """

        node = cmds.createNode("transform", n= base_name + '_vec')
        attr_name = base_name + "_from_value"
        cmds.addAttr(node, ln = attr_name, at="float",
                        k=1)
        cmds.setAttr(node + '.' + attr_name, value)

        return cls(node + '.' + attr_name , base_name) 
开发者ID:giordi91,项目名称:mMath,代码行数:23,代码来源:nVec.py

示例7: scalar_dynamic

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def scalar_dynamic (self, scal):
        '''
        This function performs a scalar multiplication

        This function is called dynamic because it uses a connection to get
        the value for the multiplication, in short it is a NScalar instance (aka a vec1)
        that gets used three times to multiply the current vector

        :scal: NScalar, a scalar class instance
        :return: NVec instance
        ''' 

        assert type(scal) == NScalar, "__sub__ ERROR: input parameter needs to be of type NScalar"

        mult = cmds.createNode("multiplyDivide", n=  self._generator.next()+ '_scalarDyn')
        cmds.connectAttr(scal.attribute_name , mult + '.input2X')
        cmds.connectAttr(scal.attribute_name , mult + '.input2Y')
        cmds.connectAttr(scal.attribute_name , mult + '.input2Z')
        cmds.connectAttr(self.attribute_name, mult + '.input1')
        return NVec.with_generator(mult+ '.output', self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:22,代码来源:nVec.py

示例8: scalar_static

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def scalar_static(self, value):
        """
        This is a static scalar multiplication of the vector

        By static it means it multiplies by a fixed value which is not dynamic 
        like an attribute connection

        Args:

        :value: float,int, the value for which we wist to scale the vector for
        :return: NVec instance
        """

        mult = cmds.createNode("multiplyDivide", n=  self._generator.next()+ '_scalarStatic')
        cmds.setAttr(mult + '.input2X',value)
        cmds.setAttr(mult + '.input2Y',value)
        cmds.setAttr(mult + '.input2Z',value)
        cmds.connectAttr(self.attribute_name, mult + '.input1')
        return NVec.with_generator(mult+ '.output', self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:21,代码来源:nVec.py

示例9: dot

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def dot(self, vecB):
        """
        This function performs a dot product

        Args:

        :vecB: NVec, the second class for the operation
        :return: NVec instance
        """ 
        assert type(vecB) == NVec, "__sub__ ERROR: input parameter needs to be of type NVec"

        vecProd = cmds.createNode("vectorProduct", n = self._generator.next()+ "_dot")
        cmds.connectAttr(self.attribute_name , vecProd + '.input1')
        cmds.connectAttr(vecB.attribute_name , vecProd + '.input2')

        return NVec.with_generator(vecProd+ '.output', self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:18,代码来源:nVec.py

示例10: cross

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def cross(self,vecB):
        """
        Cross product function 

        Args:

        :vecB: NVec, the second class for the operation
        :return: NVec instance
        """
        assert type(vecB) == NVec, "__sub__ ERROR: input parameter needs to be of type NVec"

        vecProd = cmds.createNode("vectorProduct", n = self._generator.next()+ "_cross")
        cmds.setAttr(vecProd + '.operation', 2)
        cmds.connectAttr(self.attribute_name , vecProd + '.input1')
        cmds.connectAttr(vecB.attribute_name , vecProd + '.input2')

        return NVec.with_generator(vecProd+ '.output', self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:19,代码来源:nVec.py

示例11: __sub__

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def __sub__(self,vecB):
        """
        Subtraction operator for NVec

        Args:

        :vecB: NVec, the second class for the operation
        :return: NVec instance
        """
        assert type(vecB) == NVec, "__sub__ ERROR: input parameter needs to be of type NVec"
        pma = cmds.createNode("plusMinusAverage", n = self._generator.next()+ "_sub")
        cmds.connectAttr(vecB.attribute_name, pma + '.input3D[0]')
        cmds.connectAttr(self.attribute_name, pma + '.input3D[1]')
        cmds.setAttr(pma + '.operation',2)

        return NVec.with_generator(pma+ '.output3D', self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:18,代码来源:nVec.py

示例12: convertSkelSettingsToNN

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [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

示例13: test_rouge_mode

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def test_rouge_mode():
    """CMDX_ROGUE_MODE is faster"""

    node = cmdx.createNode("transform")
    Compare("norogue", "createNode", node.name)

    with environment("CMDX_ROGUE_MODE"):
        node = cmdx.createNode("transform")
        Compare("rogue", "createNode", node.name)

    rogue_vs_norogue = (
        timings["createNode"]["norogue"]["percall"] /
        timings["createNode"]["rogue"]["percall"]
    )

    assert_greater(rogue_vs_norogue, 0.9) 
开发者ID:mottosso,项目名称:cmdx,代码行数:18,代码来源:test_performance.py

示例14: exists

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def exists(self):
        """The node exists in both memory *and* scene

        Example:
            >>> node = createNode("joint")
            >>> node.exists
            True
            >>> cmds.delete(str(node))
            >>> node.exists
            False
            >>> node.destroyed
            False
            >>> _ = cmds.file(new=True, force=True)
            >>> node.exists
            False
            >>> node.destroyed
            True

        """

        return not self._removed 
开发者ID:mottosso,项目名称:cmdx,代码行数:23,代码来源:cmdx.py

示例15: isA

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import createNode [as 别名]
def isA(self, type):
        """Evaluate whether self is of `type`

        Arguments:
            type (int): MFn function set constant

        Example:
            >>> node = createNode("transform")
            >>> node.isA(kTransform)
            True
            >>> node.isA(kShape)
            False

        """

        return self._mobject.hasFn(type) 
开发者ID:mottosso,项目名称:cmdx,代码行数:18,代码来源:cmdx.py


注:本文中的maya.cmds.createNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。