Python pymel.core.connectAttr() Examples

The following are 30 code examples of pymel.core.connectAttr(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module pymel.core , or try the search function .
Example #1
Source File: sqCopyPasteShapes.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def _duplicate_shape(old_shape):
    new_shape = pymel.createNode('nurbsCurve')

    # Transfert various attributes
    mel_dst = '{0}.create'.format(new_shape) # prevent annoying pymel warning
    pymel.connectAttr(old_shape.local, mel_dst)
    new_shape.create.evaluate() # Force maya to cache the shape before unconnecting
    pymel.disconnectAttr(old_shape.local, mel_dst)

    # Transfert various attributes
    for att_name in transferable_shape_attrs:
        att_old = old_shape.attr(att_name)
        att_new = new_shape.attr(att_name)
        att_new.set(att_old.get())

    return new_shape 
Example #2
Source File: splinerig.py    From DynRigBuilder with MIT License 6 votes vote down vote up
def _buildBaseCtrls(self):
        # create global ctrl
        self.globalCtrl = mayautils.createCtrl("{0}_all_ctrl".format(self.prefix), "crossArrow", 1, "yellow")
        globalCtrlAttr = [
            {"ln":"globalScale", "at":"float", "dv":1, "k":1},
            {"ln":self.RIG_TOP_TAG, "dt":"string"}
        ]
        mayautils.addAttributes(self.globalCtrl, globalCtrlAttr)

        # create meta ctrl
        self.metaCtrl = mayautils.createCtrl("{0}_meta_ctrl".format(self.prefix), "fatCross", 1, "yellow", None, [0,0,90])
        pm.xform(self.metaCtrl, t=self.metaPos, ws=1)
        mayautils.aimObject(self.endPos, self.metaCtrl)
        mayautils.createParentTransform("org", self.metaCtrl).setParent(self.globalCtrl)

        # build globalScale connections
        for ch in 'xyz':
            pm.connectAttr(self.globalCtrl.globalScale, "{0}.s{1}".format(self.metaCtrl.name(), ch))
            pm.setAttr("{0}.s{1}".format(self.metaCtrl.name(), ch), cb=0, keyable=0, lock=1)
            pm.setAttr("{0}.s{1}".format(self.globalCtrl.name(), ch), cb=0, keyable=0, lock=1) 
Example #3
Source File: limb.py    From anima with MIT License 6 votes vote down vote up
def make_stretchy(self):
        #check joints
        """


        """
        self._scaleMD = pm.createNode("multiplyDivide",
                                      n=self.limbName + "_scaleMD")
        pm.connectAttr(self.curve.curveInfo.arcLength, self.scaleMD.input1X)
        pm.setAttr(self.scaleMD.input2X, self.curve.arclen)
        pm.setAttr(self.scaleMD.operation, 2)

        for jnt in self.joints.jointChain:
            factor = pm.createNode("multiplyDivide", n="factor_" + jnt)
            pm.connectAttr(self.scaleMD.outputX, factor.input1X)
            pm.setAttr(factor.input2X, (pm.getAttr(jnt.ty)))
            pm.connectAttr(factor.outputX, jnt.ty) 
Example #4
Source File: pivot_switcher.py    From anima with MIT License 6 votes vote down vote up
def _save_settings(self):
        """save settings inside objects pivotData attribute
        """
        # data to be save :
        # -----------------
        # futurePivot node

        # create attributes
        self._create_data_attribute()

        # connect futurePivot node
        pm.connectAttr(
            '%s%s' % (self._futurePivot.name(), ".message"),
            self._object.attr("pivotData.futurePivot"),
            f=True
        ) 
Example #5
Source File: node.py    From mgear_core with MIT License 6 votes vote down vote up
def controller_tag_connect(ctt, tagParent):
    """Summary

    Args:
        ctt (TYPE): Teh control tag
        tagParent (TYPE): The object with the parent control tag
    """
    if pm.controller(tagParent, q=True):
        tpTagNode = pm.PyNode(pm.controller(tagParent, q=True)[0])
        tpTagNode.cycleWalkSibling.set(True)
        pm.connectAttr(tpTagNode.prepopulate, ctt.prepopulate, f=True)

        ni = attribute.get_next_available_index(tpTagNode.children)
        pm.disconnectAttr(ctt.parent)
        pm.connectAttr(ctt.parent, tpTagNode.attr(
                       "children[%s]" % str(ni))) 
Example #6
Source File: node.py    From mgear_core with MIT License 6 votes vote down vote up
def createVertexPositionNode(inShape,
                             vId=0,
                             output=None,
                             name="mgear_vertexPosition"):
    """Creates a mgear_vertexPosition node"""
    node = pm.createNode("mgear_vertexPosition", n=name)
    inShape.worldMesh.connect(node.inputShape)
    node.vertex.set(vId)
    if output:
        pm.connectAttr(output.parentInverseMatrix,
                       node.drivenParentInverseMatrix)
        pm.connectAttr(node.output, output.translate)

    return node


#############################################
# CREATE MULTI NODES
############################################# 
Example #7
Source File: node.py    From mgear_core with MIT License 6 votes vote down vote up
def createCurveInfoNode(crv):
    """Create and connect a curveInfo node.

    Arguments:
        crv (dagNode): The curve.

    Returns:
        pyNode: the newly created node.

    >>> crv_node = nod.createCurveInfoNode(self.slv_crv)

    """
    node = pm.createNode("curveInfo")

    shape = pm.listRelatives(crv, shapes=True)[0]

    pm.connectAttr(shape + ".local", node + ".inputCurve")

    return node


# TODO: update using plusMinusAverage node 
Example #8
Source File: node.py    From mgear_core with MIT License 6 votes vote down vote up
def createDecomposeMatrixNode(m):
    """
    Create and connect a decomposeMatrix node.

    Arguments:
        m(str or attr): The matrix attribute name.

    Returns:
        pyNode: the newly created node.

    >>> dm_node = nod.createDecomposeMatrixNode(mulmat_node+".output")

    """
    node = pm.createNode("decomposeMatrix")

    pm.connectAttr(m, node + ".inputMatrix")

    return node 
Example #9
Source File: attribute.py    From mgear_core with MIT License 6 votes vote down vote up
def connectSet(source, target, testInstance):
    """Connect or set attributes

    Connects or set attributes depending if is instance of a instance check

    Args:
        source (str or Attr): Striname of the attribute or PyNode attribute
        target (str or Attr): Striname of the attribute or PyNode attribute
        testInstance (tuple): Tuple of types to check
    """
    if not isinstance(testInstance, tuple):
        testInstance = tuple(testInstance)

    if isinstance(source, testInstance):
        pm.connectAttr(source, target)
    else:
        pm.setAttr(target, source) 
Example #10
Source File: applyop.py    From mgear_core with MIT License 6 votes vote down vote up
def gear_inverseRotorder_op(out_obj, in_obj):
    """
    Apply a sn_inverseRotorder_op operator

    Arguments:
        out_obj (dagNode): Output object.
        in_obj (dagNode): Input object.

    Returns:
        pyNode: The newly created operator.
    """
    node = pm.createNode("mgear_inverseRotOrder")

    pm.connectAttr(in_obj + ".ro", node + ".ro")
    pm.connectAttr(node + ".output", out_obj + ".ro")

    return node 
Example #11
Source File: applyop.py    From mgear_core with MIT License 6 votes vote down vote up
def gear_curvecns_op(crv, inputs=[]):
    """
    create mGear curvecns node.

    Arguments:
        crv (nurbsCurve): Nurbs curve.
        inputs (List of dagNodes): Input object to drive the curve. Should be
            same number as crv points.
            Also the order should be the same as the points

    Returns:
        pyNode: The curvecns node.
    """
    pm.select(crv)
    node = pm.deformer(type="mgear_curveCns")[0]

    for i, item in enumerate(inputs):
        pm.connectAttr(item + ".worldMatrix", node + ".inputs[%s]" % i)

    return node 
Example #12
Source File: applyop.py    From mgear_core with MIT License 6 votes vote down vote up
def gear_intmatrix_op(mA, mB, blend=0):
    """
    create mGear interpolate Matrix node.

    Arguments:
        mA (matrix): Input matrix A.
        mB (matrix): Input matrix A.
        blend (float or connection): Blending value.

    Returns:
        pyNode: Newly created mGear_intMatrix node
    """
    node = pm.createNode("mgear_intMatrix")

    pm.connectAttr(mA, node + ".matrixA")
    pm.connectAttr(mB, node + ".matrixB")

    if (isinstance(blend, str)
        or isinstance(blend, unicode)
            or isinstance(blend, pm.Attribute)):
        pm.connectAttr(blend, node + ".blend")
    else:
        pm.setAttr(node + ".blend", blend)

    return node 
Example #13
Source File: test_mgear_attribute.py    From mgear_core with MIT License 6 votes vote down vote up
def source_nodes():
    cmds.file(new=True, force=True)

    source1, _ = pm.polyCube(name="source1")
    source2, _ = pm.polyCube(name="source2")
    target, _ = pm.polyCube(name="target")

    ch1 = att.addAttribute(source1,
                           "chanName",
                           "double",
                           0,
                           minValue=0,
                           maxValue=1)
    ch2 = att.addAttribute(source2,
                           "chanName",
                           "double",
                           0,
                           minValue=0,
                           maxValue=1)

    pm.connectAttr(ch1, source1.ty)
    pm.connectAttr(ch2, source2.ty) 
Example #14
Source File: applyop.py    From mgear_core with MIT License 5 votes vote down vote up
def pathCns(obj, curve, cnsType=False, u=0, tangent=False):
    """
    Apply a path constraint or curve constraint.

    Arguments:
        obj (dagNode): Constrained object.
        curve (Nurbscurve): Constraining Curve.
        cnsType (int): 0 for Path Constraint, 1 for Curve
            Constraint (Parametric).
        u (float): Position of the object on the curve (from 0 to 100 for path
            constraint, from 0 to 1 for Curve cns).
        tangent (bool): Keep tangent orientation option.

    Returns:
        pyNode: The newly created constraint.
    """
    node = pm.PyNode(pm.createNode("motionPath"))
    node.setAttr("uValue", u)
    node.setAttr("fractionMode", not cnsType)
    node.setAttr("follow", tangent)

    pm.connectAttr(curve.attr("worldSpace"), node.attr("geometryPath"))
    pm.connectAttr(node.attr("allCoordinates"), obj.attr("translate"))
    pm.connectAttr(node.attr("rotate"), obj.attr("rotate"))
    pm.connectAttr(node.attr("rotateOrder"), obj.attr("rotateOrder"))
    pm.connectAttr(node.attr("message"), obj.attr("specifiedManipLocation"))

    return node

# TODO: review function to make wupObject optional 
Example #15
Source File: node.py    From mgear_core with MIT License 5 votes vote down vote up
def createPlusMinusAverage1D(input, operation=1, output=None):
    """Create a multiple average node 1D.
    Arguments:
        input (attr, float or list): The input values.
        operation (int): Node operation. 0=None, 1=sum, 2=subtract,
            3=average
        output (attr): The attribute to connect the result.

    Returns:
        pyNode: the newly created node.

    """
    if not isinstance(input, list):
        input = [input]

    node = pm.createNode("plusMinusAverage")
    node.attr("operation").set(operation)

    for i, x in enumerate(input):
        try:
            pm.connectAttr(x, node + ".input1D[%s]" % str(i))
        except RuntimeError:
            pm.setAttr(node + ".input1D[%s]" % str(i), x)

    if output:
        pm.connectAttr(node + ".output1D", output)

    return node 
Example #16
Source File: node.py    From mgear_core with MIT License 5 votes vote down vote up
def createNegateNodeMulti(name, inputs=[]):
    """Create and connect multiple negate nodes

    Arguments:
        name (str): The name for the new node.
        inputs (list of attr): The list of attributes to negate

    Returns:
        list: The output attributes list.

    """
    s = "XYZ"
    count = 0
    i = 0
    outputs = []
    for input in inputs:
        if count == 0:
            real_name = name + "_" + str(i)
            node_name = pm.createNode("multiplyDivide", n=real_name)
            i += 1

        pm.connectAttr(input, node_name + ".input1" + s[count], f=True)
        pm.setAttr(node_name + ".input2" + s[count], -1)

        outputs.append(node_name + ".output" + s[count])
        count = (count + 1) % 3

    return outputs 
Example #17
Source File: node.py    From mgear_core with MIT License 5 votes vote down vote up
def createAddNodeMulti(inputs=[]):
    """Create and connect multiple add nodes

    Arguments:
        inputs (list of attr): The list of attributes to add

    Returns:
        list: The output attributes list.

    >>> angle_outputs = nod.createAddNodeMulti(self.angles_att)

    """
    outputs = [inputs[0]]

    for i, input in enumerate(inputs[1:]):
        node_name = pm.createNode("addDoubleLinear")

        if (isinstance(outputs[-1], str)
                or isinstance(outputs[-1], unicode)
                or isinstance(outputs[-1], pm.Attribute)):
            pm.connectAttr(outputs[-1], node_name + ".input1", f=True)
        else:
            pm.setAttr(node_name + ".input1", outputs[-1])

        if (isinstance(input, str)
                or isinstance(input, unicode)
                or isinstance(input, pm.Attribute)):
            pm.connectAttr(input, node_name + ".input2", f=True)
        else:
            pm.setAttr(node_name + ".input2", input)

        outputs.append(node_name + ".output")

    return outputs 
Example #18
Source File: node.py    From mgear_core with MIT License 5 votes vote down vote up
def createMulNodeMulti(name, inputs=[]):
    """Create and connect multiple multiply nodes

    Arguments:
        name (str): The name for the new node.
        inputs (list of attr): The list of attributes to multiply

    Returns:
        list: The output attributes list.

    """
    outputs = [inputs[0]]

    for i, input in enumerate(inputs[1:]):
        real_name = name + "_" + str(i)
        node_name = pm.createNode("multiplyDivide", n=real_name)
        pm.setAttr(node_name + ".operation", 1)

        if (isinstance(outputs[-1], str)
                or isinstance(outputs[-1], unicode)
                or isinstance(outputs[-1], pm.Attribute)):
            pm.connectAttr(outputs[-1], node_name + ".input1X", f=True)
        else:
            pm.setAttr(node_name + ".input1X", outputs[-1])

        if (isinstance(input, str)
                or isinstance(input, unicode)
                or isinstance(input, pm.Attribute)):
            pm.connectAttr(input, node_name + ".input2X", f=True)
        else:
            pm.setAttr(node_name + ".input2X", input)

        outputs.append(node_name + ".output")

    return outputs 
Example #19
Source File: applyop.py    From mgear_core with MIT License 5 votes vote down vote up
def oriCns(driver, driven, maintainOffset=False):
    """Apply orientation constraint

    Apply orientation constraint changing XYZ  default connexions by
    rotate compound connexions

    Note:
        We have found an evaluation difference in the values if the connexion
        is compound or by axis

    Arguments:
        driver (dagNode or dagNode list): Driver object.
        driven (dagNode): Driven object.
        maintainOffset (bool): Keep the offset.

    Returns:
        pyNode: Orientation constraintn node.

    Example:
        .. code-block:: python

            import mgear.core.applyop as aop
            import pymel.core as pm
            sphere = pm.polySphere(n='sphereDriver')
            cube = pm.polyCube(n='cubeDriven')
            ori_cns = aop.oriCns(sphere[0], cube[0], True)

    """
    oriCns = pm.orientConstraint(driver, driven, maintainOffset=maintainOffset)
    for axis in "XYZ":
        pm.disconnectAttr(oriCns + ".constraintRotate" + axis,
                          driven + ".rotate" + axis)
    pm.connectAttr(oriCns + ".constraintRotate", driven + ".rotate", f=True)

    return oriCns 
Example #20
Source File: applyop.py    From mgear_core with MIT License 5 votes vote down vote up
def curvecns_op(crv, inputs=[]):

    for i, item in enumerate(inputs):
        node = pm.createNode("decomposeMatrix")
        pm.connectAttr(item + ".worldMatrix[0]", node + ".inputMatrix")
        pm.connectAttr(node + ".outputTranslate",
                       crv + ".controlPoints[%s]" % i)

    return node 
Example #21
Source File: auxiliary.py    From anima with MIT License 5 votes vote down vote up
def export_blend_connections():
    """Exports the connection commands from selected objects to the blendShape
    of another object. The resulted text file contains all the MEL scripts to
    reconnect the objects to the blendShape node. So after exporting the
    connection commands you can export the blendShape targets as another maya
    file and delete them from the scene, thus your scene gets lite and loads
    much more quickly.
    """
    selection_list = pm.ls(tr=1, sl=1, l=1)

    dialog_return = pm.fileDialog2(cap="Save As", fm=0, ff='Text Files(*.txt)')

    filename = dialog_return[0]
    print(filename)

    print("\n\nFiles written:\n--------------------------------------------\n")

    with open(filename, 'w') as fileId:
        for i in range(0, len(selection_list)):
            shapes = pm.listRelatives(selection_list[i], s=True, f=True)

            main_shape = ""
            for j in range(0, len(shapes)):
                if pm.getAttr(shapes[j] + '.intermediateObject') == 0:
                    main_shape = shapes
                    break
            if main_shape == "":
                main_shape = shapes[0]

            con = pm.listConnections(main_shape, t="blendShape", c=1, s=1, p=1)

            cmd = "connectAttr -f %s.worldMesh[0] %s;" % (
                ''.join(map(str, main_shape)),
                ''.join(map(str, con[0].name()))
            )
            print("%s\n" % cmd)
            fileId.write("%s\n" % cmd)

    print("\n------------------------------------------------------\n")
    print("filename: %s     ...done\n" % filename) 
Example #22
Source File: network.py    From anima with MIT License 5 votes vote down vote up
def attach(self, object):
        #it connects the given object to the network and return an id number
        # for the object
        #all_cons = pm.listConnections(self.name)
        if not object in self.connections:
            mayaCon = object + ('.message')
            networkId = len(self.connections)
            tempAttr = '%s[%s]' % ("affectedBy", networkId)
            networkCon = self.name + "." + tempAttr
            pm.connectAttr(mayaCon, networkCon)
            self.connections.append(object) 
Example #23
Source File: curve.py    From anima with MIT License 5 votes vote down vote up
def _create_curveInfo(self):
        #create a new CurveInfo Node
        self._curveInfo = pm.createNode("curveInfo", n= self._curveNode +
                                                        "_curveInfo")
        pm.connectAttr(self._curveNode.worldSpace, self._curveInfo.inputCurve)
        return self._curveInfo 
Example #24
Source File: utilityFuncs.py    From anima with MIT License 5 votes vote down vote up
def connect(sourceObj, sourceAttr, destObj, destAttr):
        source = sourceObj + "." + sourceAttr
        dest = destObj + "." + destAttr
        pm.connectAttr(source, dest) 
Example #25
Source File: dpPoseReader.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def on_action_axisChange(self, iRow, iCol, *args):
        pCell = self.ui.tblData.item(iRow,iCol)
        pData = pCell.data(QtCore.Qt.UserRole)

        pData.nChildLoc.axis.set(args[0])

        #Delete old connection
        pymel.disconnectAttr(pData.nMD.input1X)

        lstXCon = pData.nDecM.outputRotateX.listConnections()
        pymel.disconnectAttr(pData.nDecM.outputRotateX)
        pymel.delete(lstXCon)

        lstYCon = pData.nDecM.outputRotateY.listConnections()
        pymel.disconnectAttr(pData.nDecM.outputRotateY)
        pymel.delete(lstYCon)

        lstZCon = pData.nDecM.outputRotateZ.listConnections()
        pymel.disconnectAttr(pData.nDecM.outputRotateZ)
        pymel.delete(lstZCon)

        if args[0] == 0:
            pymel.connectAttr(pData.nDecM.outputRotateX, pData.nMD.input1X, f=True)
        elif args[0] == 1:
             pymel.connectAttr(pData.nDecM.outputRotateY, pData.nMD.input1X, f=True)
        elif args[0] == 2:
             pymel.connectAttr(pData.nDecM.outputRotateZ, pData.nMD.input1X, f=True)

    #Change the axis connection of the system to connect in the good axis 
Example #26
Source File: mayautils.py    From DynRigBuilder with MIT License 5 votes vote down vote up
def connectChannels(source, destination, channels='trsv'):
    """
    Connect the specified channels of the source and destination objects.
    :param source: `PyNode` source object
    :param destination: `PyNode` destination object
    :param channels: `string` channels to connect
    :return:
    """
    for channel in channels:
        pm.connectAttr("{0}.{1}".format(source.name(), channel),
                       "{0}.{1}".format(destination.name(), channel)) 
Example #27
Source File: core.py    From metanode with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set(self, attr_name, value):
        """
        Set the value of the given attribute. Attribute name must be registered in one of the attr dictionaries.
        Currently supports attributes of type message, string, bool, float, int, enum

        :param attr_name: Name of attribute to edit
        :param value: List or single value representing value of attribute to set
        """
        # Get attribute data
        attr_data = self._get_attr_data(attr_name)
        # If multi: (value should be list)
        if attr_data.get('multi', False):
            if not isinstance(value, (list, tuple)):
                raise ValueError(
                    "'{0}' is a multi attribute and must be set with a list or tuple of data".format(attr_name))
            # Data Type: MESSAGE
            if attr_data.get('at') == 'message':
                for attr_element in self.node.attr(attr_name):
                    pm.removeMultiInstance(attr_element, b=True)
                # Value should be list of PyNodes, we connect node.message to slot
                for index, item in enumerate(value):
                    pm.connectAttr(item.message, self.node.attr(attr_name)[index])
            # Data Type: STRING/BOOL/FLOAT/INT/ENUM
            else:
                for attr_element in self.node.attr(attr_name):
                    pm.removeMultiInstance(attr_element, b=True)
                for index, item in enumerate(value):
                    self.node.attr(attr_name)[index].set(item)
        # If not multi:
        else:
            # Data Type: MESSAGE
            if attr_data.get('at') == 'message':
                # Value should be a PyNode, we connect node.message to slot
                if value is not None:
                    pm.connectAttr(value.message, self.node.attr(attr_name))
                # If value is None, disconnect the current value
                else:
                    pm.disconnectAttr(self.node.attr(attr_name), inputs=True)
            # Data Type: STRING/BOOL/FLOAT/INT/ENUM
            else:
                self.node.attr(attr_name).set(value) 
Example #28
Source File: applyop.py    From mgear_core with MIT License 5 votes vote down vote up
def gear_spinePointAtOpWM(cns, startobj, endobj, blend=.5, axis="-Z"):
    """
    Apply a SpinePointAt operator using world matrix

    Arguments:
        cns Constraint: The constraint to apply the operator on (must be a
            curve, path or direction constraint).
        startobj (dagNode): Start Reference.
        endobj (dagNode): End Reference.
        blend (float): Blend influence value from 0 to 1.
        axis (str): Axis direction.

    Returns:
        pyNode: The newly created operator.
    """
    node = pm.createNode("mgear_spinePointAt")

    # Inputs
    pm.setAttr(node + ".blend", blend)
    pm.setAttr(node + ".axe", ["X", "Y", "Z", "-X", "-Y", "-Z"].index(axis))

    dem_node1 = pm.createNode("decomposeMatrix")
    dem_node2 = pm.createNode("decomposeMatrix")
    pm.connectAttr(startobj + ".worldMatrix", dem_node1 + ".inputMatrix")
    pm.connectAttr(endobj + ".worldMatrix", dem_node2 + ".inputMatrix")

    pm.connectAttr(dem_node1 + ".outputRotate", node + ".rotA")
    pm.connectAttr(dem_node2 + ".outputRotate", node + ".rotB")

    # Outputs
    pm.setAttr(cns + ".worldUpType", 3)

    pm.connectAttr(node + ".pointAt", cns + ".worldUpVector")

    return node 
Example #29
Source File: node.py    From mgear_core with MIT License 5 votes vote down vote up
def createDivNode(inputA, inputB, output=None):
    """Create and connect a Divide node.

    Arguments:
        inputA (attr, float or list of float): The attribute input A
        inputB (attr, float or list of float): The attribute input B
        output (attr or list of attr): The attribute to connect the
            output.

    Returns:
        pyNode: the newly created node.

    Example:
        .. code-block:: python

            # Classic Maya style creation and connection = 4 lines
            div1_node = pm.createNode("multiplyDivide")
            div1_node.setAttr("operation", 2)
            div1_node.setAttr("input1X", 1)
            pm.connectAttr(self.rig.global_ctl+".sx",
                           div1_node+".input2X")

            # mGear style = 1 line
            div1_node = nod.createDivNode(1.0,
                                          self.rig.global_ctl+".sx")

    """
    return createMulDivNode(inputA, inputB, 2, output) 
Example #30
Source File: node.py    From mgear_core with MIT License 5 votes vote down vote up
def createSubNode(inputA, inputB):
    """Create and connect a subtraction node.

    Arguments:
        inputA (attr or float): The attribute input A
        inputB (attr or float): The attribute input B

    Returns:
        pyNode: the newly created node.

    >>> sub_nod = nod.createSubNode(self.roll_att, angle_outputs[i-1])

    """
    node = pm.createNode("addDoubleLinear")

    if (isinstance(inputA, str)
            or isinstance(inputA, unicode)
            or isinstance(inputA, pm.Attribute)):
        pm.connectAttr(inputA, node + ".input1")
    else:
        pm.setAttr(node + ".input1", inputA)

    if (isinstance(inputB, str)
            or isinstance(inputB, unicode)
            or isinstance(inputB, pm.Attribute)):
        neg_node = pm.createNode("multiplyDivide")
        pm.connectAttr(inputB, neg_node + ".input1X")
        pm.setAttr(neg_node + ".input2X", -1)
        pm.connectAttr(neg_node + ".outputX", node + ".input2")
    else:
        pm.setAttr(node + ".input2", -inputB)

    return node