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


Python cmds.connectAttr方法代码示例

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


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

示例1: dpIsolate

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

示例2: twistBoneMatrix

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

示例3: __normalizeSlideAttributes

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

示例4: scalar_dynamic

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def scalar_dynamic(self, scalB):
        """
        The dynamic mult for the NScalar class

        By dynamic I mean that the scalB value is going to be driven by a connection,
        thus needs to be a NScalar instance.

        :scalB: NScalar, the scalar to be multiplied by
        :return: NScalar instance
        """

        md = self._generate_node("multDoubleLinear", "mul")
        cmds.connectAttr(self.attribute_name, md + '.input1')
        cmds.connectAttr(scalB.attribute_name, md + '.input2')

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

示例5: scalar_static

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def scalar_static(self, value):
        """
        The static mult for the NScalar class

        By static  I mean that the scalB value is going to hardcoded in the 
        node performing the operation, which means it wont change over time

        :value: int,float, the value to be multiplied by
        :return: NScalar instance
        """

        md = self._generate_node("multDoubleLinear", "mul")
        cmds.connectAttr(self.attribute_name, md + '.input1')
        cmds.setAttr(md + '.input2',value)

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

示例6: division_dynamic

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def division_dynamic(self, scalB):
        """
        The dynamic divison for the NScalar class

        By dynamic I mean that the scalB value is going to be driven by a connection,
        thus needs to be a NScalar instance.

        :scalB: NScalar, the scalar to be divided by
        :return: NScalar instance
        """

        md = self._generate_node("multiplyDivide", "div")
        cmds.connectAttr(self.attribute_name, md + '.input1X')
        cmds.connectAttr(scalB.attribute_name, md + '.input2X')
        cmds.setAttr(md + '.operation',2)

        return NScalar.with_generator(md + ".outputX", self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:19,代码来源:nVec.py

示例7: division_static

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def division_static(self,value):
        """
        The static divison for the NScalar class

        By static I mean that the scalB value is going to be static and hardcoded,
        in the node. Meant for value not changing over time

        Args:

        :value: float,int, the value needed for the operation
        :return: NScalar instance
        """

        md = self._generate_node("multiplyDivide", "div")
        cmds.connectAttr(self.attribute_name, md + '.input1X')
        cmds.setAttr(md + '.input2X', value)
        cmds.setAttr(md + '.operation',2)

        return NScalar.with_generator(md + ".outputX", self._generator) 
开发者ID:giordi91,项目名称:mMath,代码行数:21,代码来源:nVec.py

示例8: dot

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

示例9: cross

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

示例10: __sub__

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

示例11: dpLimitTranslate

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def dpLimitTranslate(self, fCtrl, ctrlName, axis, *args):
        """ Create a hyperbolic setup to limit min and max value for translation of the control.
            Resuming it's just divide 1 by the calibrate value.
        """
        hyperboleTLimitMD = cmds.createNode("multiplyDivide", name=ctrlName+"_LimitT"+axis+"_MD")
        hyperboleInvMD = cmds.createNode("multiplyDivide", name=ctrlName+"_LimitT"+axis+"_Inv_MD")
        cmds.setAttr(hyperboleTLimitMD+".input1X", 1)
        cmds.setAttr(hyperboleTLimitMD+".operation", 2)
        cmds.setAttr(hyperboleInvMD+".input2X", -1)
        cmds.connectAttr(fCtrl+".calibrateT"+axis, hyperboleTLimitMD+".input2X", force=True)
        cmds.connectAttr(hyperboleTLimitMD+".outputX", fCtrl+".maxTransLimit.maxTrans"+axis+"Limit", force=True)
        cmds.connectAttr(hyperboleTLimitMD+".outputX", hyperboleInvMD+".input1X", force=True)
        cmds.connectAttr(hyperboleInvMD+".outputX", fCtrl+".minTransLimit.minTrans"+axis+"Limit", force=True) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:15,代码来源:dpFacialControl.py

示例12: dpCreateRemapNode

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

示例13: dpInvertAttrTranformation

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def dpInvertAttrTranformation(self, nodeName, invT=True, invR=False, *args):
        """ Creates a setup to invert attribute transformations in order to avoid doubleTransformation.
        """
        axisList = ['X', 'Y', 'Z']
        if cmds.objExists(nodeName):
            nodePivot = cmds.xform(nodeName, query=True, worldSpace=True, rotatePivot=True)
            if invR:
                invRGrp = cmds.group(nodeName, name=nodeName+"_InvR_Grp")
                cmds.xform(invRGrp, worldSpace=True, rotatePivot=(nodePivot[0], nodePivot[1], nodePivot[2]), rotateOrder="zyx")
                rMD = cmds.createNode('multiplyDivide', name=nodeName+"_InvR_MD", skipSelect=True)
                cmds.setAttr(rMD+'.input2X', -1)
                cmds.setAttr(rMD+'.input2Y', -1)
                cmds.setAttr(rMD+'.input2Z', -1)
                for axis in axisList:
                    cmds.connectAttr(nodeName+'.rotate'+axis, rMD+'.input1'+axis, force=True)
                    cmds.connectAttr(rMD+'.output'+axis, invRGrp+'.rotate'+axis, force=True)
            if invT:
                invTGrp = cmds.group(nodeName, name=nodeName+"_InvT_Grp")
                cmds.xform(invTGrp, worldSpace=True, rotatePivot=(nodePivot[0], nodePivot[1], nodePivot[2]))
                tMD = cmds.createNode('multiplyDivide', name=nodeName+"_InvT_MD", skipSelect=True)
                cmds.setAttr(tMD+'.input2X', -1)
                cmds.setAttr(tMD+'.input2Y', -1)
                cmds.setAttr(tMD+'.input2Z', -1)
                for axis in axisList:
                    cmds.connectAttr(nodeName+'.translate'+axis, tMD+'.input1'+axis, force=True)
                    cmds.connectAttr(tMD+'.output'+axis, invTGrp+'.translate'+axis, force=True) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:28,代码来源:dpRivet.py

示例14: sqCreateStikyLipsDeformers

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def sqCreateStikyLipsDeformers(self, *args):
        baseMesh = None
        mainCurveList = [self.mainCurveA, self.mainCurveB]
        for mainCurve in mainCurveList:
            if baseMesh == None:
                baseMesh = cmds.duplicate(self.receptList[0], name=self.receptList[0]+"Base")[0]
                cmds.setAttr(baseMesh+".visibility", 0)
            
            wrapNode = cmds.deformer(mainCurve, name="StickyLips_Wrap", type="wrap")[0]
            try:
                cmds.connectAttr(self.receptList[0]+".dropoff", wrapNode+".dropoff[0]", force=True)
                cmds.connectAttr(self.receptList[0]+".inflType", wrapNode+".inflType[0]", force=True)
                cmds.connectAttr(self.receptList[0]+".smoothness", wrapNode+".smoothness[0]", force=True)
                cmds.connectAttr(self.receptList[0]+"Shape.worldMesh[0]", wrapNode+".driverPoints[0]", force=True)
            except:
                pass
            
            cmds.connectAttr(baseMesh+"Shape.worldMesh[0]", wrapNode+".basePoints[0]", force=True)
            cmds.connectAttr(mainCurve+"Shape.worldMatrix[0]", wrapNode+".geomMatrix", force=True)
            cmds.setAttr(wrapNode+".maxDistance", 1)
            cmds.setAttr(wrapNode+".autoWeightThreshold", 1)
            cmds.setAttr(wrapNode+".exclusiveBind", 1)
            
        baseCurveList = [self.baseCurveA, self.baseCurveB]
        for c, baseCurve in enumerate(baseCurveList):
            wireNode = cmds.wire(self.receptList[1], name=baseCurve+"_Wire", groupWithBase=False, crossingEffect=0, localInfluence=0)[0]
            cmds.connectAttr(mainCurveList[c]+"Shape.worldSpace[0]", wireNode+".baseWire[0]", force=True)
            cmds.connectAttr(baseCurve+"Shape.worldSpace[0]", wireNode+".deformedWire[0]", force=True)
            self.wireNodeList.append(wireNode)
            
            wireLocList = []
            for i in range(0, self.maxIter):
                wireLocList.append(baseCurve+".u["+str(i)+"]")
            cmds.dropoffLocator(1, 1, wireNode, wireLocList) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:36,代码来源:sqStickyLipsSetup.py

示例15: directConnect

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import connectAttr [as 别名]
def directConnect(self, fromObj, toObj, attrList=['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'], f=True, *args):
        """Connect attributes from list directely between two objects given.
        """
        if cmds.objExists(fromObj) and cmds.objExists(toObj):
            for attr in attrList:
                try:
                    # connect attributes:
                    cmds.connectAttr(fromObj+"."+attr, toObj+"."+attr, force=f)
                except:
                    print "Error: Cannot connect", toObj, ".", attr, "directely." 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:12,代码来源:dpControls.py


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