Python maya.cmds.joint() Examples

The following are 30 code examples of maya.cmds.joint(). 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 maya.cmds , or try the search function .
Example #1
Source File: test_skeleton.py    From cmt with MIT License 6 votes vote down vote up
def assert_hierarachies_match(self):
        self.assertEqual(7, len(cmds.ls(type="joint")))
        # Make sure the joint orients are the same
        translates = [cmds.getAttr("{0}.t".format(x))[0] for x in cmds.ls(type="joint")]
        rotates = [cmds.getAttr("{0}.r".format(x))[0] for x in cmds.ls(type="joint")]
        orients = [cmds.getAttr("{0}.jo".format(x))[0] for x in cmds.ls(type="joint")]
        for orient, new_orient in zip(self.orients, orients):
            self.assertListAlmostEqual(orient, new_orient)
        for translate, new_translate in zip(self.translates, translates):
            self.assertListAlmostEqual(translate, new_translate)
        for rotate, new_rotate in zip(self.rotates, rotates):
            self.assertListAlmostEqual(rotate, new_rotate)
        # The geometry should not have been exported
        self.assertFalse(cmds.objExists(self.cube))
        self.assertTrue(cmds.objExists(self.group))
        self.assertEqual("joint1", cmds.listRelatives(self.group, children=True)[0]) 
Example #2
Source File: dpEye.py    From dpAutoRigSystem with GNU General Public License v2.0 6 votes vote down vote up
def createEyelidJoints(self, side, lid, middle, cvEyelidLoc, jointLabelNumber, *args):
        ''' Create the eyelid joints to be used in the needed setup.
            Returns EyelidBaseJxt and EyelidJnt created for rotate and skinning.
        '''
        # declating a concatenated name used for base to compose:
        baseName = side+self.userGuideName+"_"+self.langDic[self.langName][lid]+"_"+self.langDic[self.langName]['c042_eyelid']+middle
        # creating joints:
        eyelidBaseZeroJxt = cmds.joint(name=baseName+"_Base_Zero_Jxt", rotationOrder="yzx", scaleCompensate=False)
        eyelidBaseJxt = cmds.joint(name=baseName+"_Base_Jxt", rotationOrder="yzx", scaleCompensate=False)
        eyelidZeroJxt = cmds.joint(name=baseName+"_Zero_Jxt", rotationOrder="yzx", scaleCompensate=False)
        eyelidJnt = cmds.joint(name=baseName+"_Jnt", rotationOrder="yzx", scaleCompensate=False)
        cmds.addAttr(eyelidJnt, longName='dpAR_joint', attributeType='float', keyable=False)
        utils.setJointLabel(eyelidJnt, jointLabelNumber, 18, self.userGuideName+"_"+self.langDic[self.langName][lid]+"_"+self.langDic[self.langName]['c042_eyelid']+middle)
        cmds.select(eyelidZeroJxt)
        eyelidSupportJxt = cmds.joint(name=baseName+"_Jxt", rotationOrder="yzx", scaleCompensate=False)
        cmds.setAttr(eyelidSupportJxt+".translateX", self.ctrlRadius*0.1)
        # positioning and orienting correctely eyelid joints:
        cmds.delete(cmds.aimConstraint(cvEyelidLoc, eyelidBaseZeroJxt, aimVector=(0,0,1), worldUpType="objectrotation", worldUpObject=self.eyelidJxt))
        cmds.delete(cmds.parentConstraint(cvEyelidLoc, eyelidZeroJxt, mo=False))
        cmds.setAttr(eyelidZeroJxt+".rotateX", 0)
        cmds.setAttr(eyelidZeroJxt+".rotateY", 0)
        cmds.setAttr(eyelidZeroJxt+".rotateZ", 0)
        cmds.select(self.eyelidJxt)
        return eyelidBaseJxt, eyelidJnt 
Example #3
Source File: test_skeleton.py    From cmt with MIT License 6 votes vote down vote up
def setUp(self):
        self.group = cmds.createNode("transform", name="skeleton_grp")
        cmds.select(cl=True)
        j1 = cmds.joint(p=(0, 10, 0))
        cmds.joint(p=(1, 9, 0))
        cmds.joint(p=(2, 8, 0))
        j = cmds.joint(p=(3, 9, 0))
        cmds.joint(p=(4, 6, 0))
        cmds.joint(p=(5, 5, 0))
        cmds.joint(p=(6, 3, 0))
        self.cube = cmds.polyCube()[0]
        cmds.parent(self.cube, j)
        cmds.parent(j1, self.group)

        cmds.joint(j1, e=True, oj="xyz", secondaryAxisOrient="yup", ch=True, zso=True)
        self.translates = [
            cmds.getAttr("{0}.t".format(x))[0] for x in cmds.ls(type="joint")
        ]
        self.rotates = [
            cmds.getAttr("{0}.r".format(x))[0] for x in cmds.ls(type="joint")
        ]
        self.orients = [
            cmds.getAttr("{0}.jo".format(x))[0] for x in cmds.ls(type="joint")
        ] 
Example #4
Source File: orientjoints.py    From cmt with MIT License 6 votes vote down vote up
def offset_orient(joints, amount, axis):
    """Offsets the orient by the given amount

    @param joints: Joints to orient.
    @param amount: Amount to offset by.
    @param axis: Which axis X, Y or Z
    """
    for joint in joints:
        children = _unparent_children(joint)
        attribute = "{0}.jointOrient{1}".format(joint, axis)
        orient = cmds.getAttr(attribute)
        orient += amount
        cmds.setAttr(attribute, orient)
        _reparent_children(joint, children)

    if joints:
        cmds.select(joints) 
Example #5
Source File: orientjoints.py    From cmt with MIT License 6 votes vote down vote up
def orient_to_world(joints):
    """Orients the given joints with the world.

    @param joints: Joints to orient.
    """
    for joint in joints:
        children = _unparent_children(joint)
        parent = cmds.listRelatives(joint, parent=True, path=True)
        orig_joint = joint.split("|")[-1]
        if parent:
            joint = cmds.parent(joint, world=True)[0]
        cmds.joint(joint, e=True, oj="none", zso=True)
        if parent:
            joint = cmds.parent(joint, parent)[0]
            joint = cmds.rename(joint, orig_joint)
        _reparent_children(joint, children)

    if joints:
        cmds.select(joints) 
Example #6
Source File: skeleton.py    From cmt with MIT License 6 votes vote down vote up
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 
Example #7
Source File: orientjoints.py    From cmt with MIT License 6 votes vote down vote up
def align_with_child(joints):
    """Aligns the up axis of the given joints with their respective child joint.

    @param joints: List of joints to orient.
    """
    for joint in joints:
        children = _unparent_children(joint)
        if children:
            cmds.delete(
                cmds.aimConstraint(
                    children[0],
                    joint,
                    aim=(1, 0, 0),
                    upVector=(0, 1, 0),
                    worldUpType="objectrotation",
                    worldUpVector=(0, 1, 0),
                    worldUpObject=children[0],
                )
            )
            cmds.makeIdentity(joint, apply=True)
        _reparent_children(joint, children)

    if joints:
        cmds.select(joints) 
Example #8
Source File: orientjoints.py    From cmt with MIT License 6 votes vote down vote up
def make_position_planar(*args):
    sel = cmds.ls(sl=True, type="joint")
    if len(sel) <= 3:
        raise RuntimeError(
            "Select 3 joints to make a plane and then additional joints to move onto that plane."
        )
    a, b, c = [get_position(sel[i]) for i in range(3)]
    ab = (b - a).normal()
    ac = (c - a).normal()
    normal = (ab ^ ac).normal()
    joints = sel[3:]
    for joint in joints:
        children = _unparent_children(joint)
        p = get_position(joint)
        pa = a - p
        dot = pa * normal
        p = p + (normal * dot)
        cmds.xform(joint, ws=True, t=(p.x, p.y, p.z))
        _reparent_children(joint, children)

    if sel:
        cmds.select(sel) 
Example #9
Source File: skeleton.py    From cmt with MIT License 6 votes vote down vote up
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) 
Example #10
Source File: skeleton.py    From cmt with MIT License 6 votes vote down vote up
def mirror(joint, search_for, replace_with):
    joints = [joint] + (cmds.listRelatives(joint, ad=True, path=True) or [])
    for joint in joints:
        mirrored_joint = joint.replace(search_for, replace_with)
        if cmds.objExists(mirrored_joint):
            translate = list(cmds.getAttr("{0}.t".format(joint))[0])
            parent = cmds.listRelatives(joint, parent=True, path=True)
            if parent and search_for not in parent[0]:
                translate[2] *= -1.0
            else:
                translate = [x * -1.0 for x in translate]
            cmds.setAttr("{0}.t".format(mirrored_joint), *translate)

            rotate = cmds.getAttr("{0}.r".format(joint))[0]
            cmds.setAttr("{0}.r".format(mirrored_joint), *rotate)

            scale = cmds.getAttr("{0}.s".format(joint))[0]
            cmds.setAttr("{0}.s".format(mirrored_joint), *scale) 
Example #11
Source File: transform.py    From SISideBar with MIT License 6 votes vote down vote up
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() 
Example #12
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def offset_orient_y(self, direction):
        joints = cmds.ls(sl=True, type="joint") or []
        amount = cmds.floatField(self.offset_y, q=True, value=True) * direction
        offset_orient(joints, amount, Axis.y) 
Example #13
Source File: test_cmt_twist_decomposition.py    From cmt with MIT License 5 votes vote down vote up
def setUp(self):
        self.start_joint = cmds.joint(p=(-0.3, -0.5, 0), name="start_joint")
        self.end_joint = cmds.joint(p=(0.5, 2.0, 0), name="end_joint")
        cmds.joint(
            self.start_joint, e=True, oj="xyz", secondaryAxisOrient="yup", zso=True
        )
        cmds.setAttr("{}.jo".format(self.end_joint), 0, 0, 0)
        self.twist_joint = cmds.duplicate(self.end_joint, name="twist_joint")[0]
        cmds.delete(
            cmds.pointConstraint(self.start_joint, self.end_joint, self.twist_joint)
        )
        self.world_plug = "{}.worldMatrix[0]".format(self.twist_joint)
        self.rest_m = self.local_matrix()
        self.tx = cmds.getAttr("{}.tx".format(self.twist_joint)) 
Example #14
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def make_planar(self, *args):
        joints = cmds.ls(sl=True, type="joint") or []
        make_planar(joints) 
Example #15
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def align_with_child(self, *args):
        joints = cmds.ls(sl=True, type="joint") or []
        align_with_child(joints) 
Example #16
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def orient_to_world(self, *args):
        joints = cmds.ls(sl=True, type="joint") or []
        orient_to_world(joints) 
Example #17
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def offset_orient_x(self, direction):
        joints = cmds.ls(sl=True, type="joint") or []
        amount = cmds.floatField(self.offset_x, q=True, value=True) * direction
        offset_orient(joints, amount, Axis.x) 
Example #18
Source File: dpFkLine.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def createGuide(self, *args):
        Base.StartClass.createGuide(self)
        # Custom GUIDE:
        cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long')
        cmds.setAttr(self.moduleGrp+".nJoints", 1)
        
        cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool')
        cmds.setAttr(self.moduleGrp+".flip", 0)
        
        cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string')
        
        self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001)
        cmds.setAttr(self.jGuide1+".template", 1)
        cmds.parent(self.jGuide1, self.moduleGrp, relative=True)
        
        self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        cmds.parent(self.cvEndJoint, self.cvJointLoc)
        cmds.setAttr(self.cvEndJoint+".tz", 1.3)
        self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001)
        cmds.setAttr(self.jGuideEnd+".template", 1)
        cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False))
        self.ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
        
        cmds.parent(self.cvJointLoc, self.moduleGrp)
        cmds.parent(self.jGuideEnd, self.jGuide1)
        cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint")
        cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint") 
Example #19
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def offset_orient_z(self, direction):
        joints = cmds.ls(sl=True, type="joint") or []
        amount = cmds.floatField(self.offset_z, q=True, value=True) * direction
        offset_orient(joints, amount, Axis.z) 
Example #20
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def zero_orient(joints):
    for joint in joints:
        children = _unparent_children(joint)
        cmds.setAttr("{0}.jointOrient".format(joint), 0, 0, 0)
        _reparent_children(joint, children)

    if joints:
        cmds.select(joints) 
Example #21
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def _reparent_children(joint, children):
    """Helper function to reparent any children of the given joint.
    @param joint: Joint whose children to reparent.
    @param children: List of transforms to reparent
    """
    for child in children:
        cmds.parent(child, joint) 
Example #22
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def template_joints(joints=None, reorient_children=True, reset_orientation=True):
    if joints is None:
        joints = cmds.ls(sl=True, type="joint")
    if not joints:
        raise RuntimeError("No joint selected to orient.")

    if reorient_children:
        children = cmds.listRelatives(fullPath=True, allDescendents=True, type="joint")
        joints.extend(children)

    red, green, blue = create_shaders()

    orient_group = cmds.createNode("transform", name=ORIENT_GROUP)
    manips = []
    for joint in joints:
        if reset_orientation:
            cmds.makeIdentity(joint, apply=True)
            cmds.joint(
                joint,
                edit=True,
                orientJoint="xyz",
                secondaryAxisOrient="yup",
                children=False,
                zeroScaleOrient=True,
            )
        if not cmds.listRelatives(joint, children=True):
            zero_orient([joint])
            continue
        group, manip = create_orient_manipulator(joint, blue)
        manips.append(manip)
        cmds.parent(group, orient_group)
        cmds.parentConstraint(joint, group)
        cmds.setAttr(joint + ".template", 1)
    cmds.select(manips) 
Example #23
Source File: orientjoints.py    From cmt with MIT License 5 votes vote down vote up
def create_orient_manipulator(joint, material):
    joint_scale = cmds.jointDisplayScale(query=True)
    joint_radius = cmds.getAttr("{0}.radius".format(joint))
    radius = joint_scale * joint_radius
    children = cmds.listRelatives(joint, children=True, path=True)
    if children:
        p1 = cmds.xform(joint, q=True, ws=True, t=True)
        p1 = OpenMaya.MPoint(*p1)
        p2 = cmds.xform(children[0], q=True, ws=True, t=True)
        p2 = OpenMaya.MPoint(*p2)
        radius = p1.distanceTo(p2)
    arrow_cvs = [
        [-1, 0, 0],
        [-1, 2, 0],
        [-2, 2, 0],
        [0, 4, 0],
        [2, 2, 0],
        [1, 2, 0],
        [1, 0, 0],
        [-1, 0, 0],
    ]
    arrow_cvs = [[x[0] * radius, x[1] * radius, x[2] * radius] for x in arrow_cvs]
    shape = cmds.curve(name="{0}_zForward".format(joint), degree=1, point=arrow_cvs)
    # shape = cmds.sphere(n='{0}_zForward'.format(joint), p=(0, 0, 0), ax=(0, 0, -1), ssw=0, esw=180, r=radius, d=3, ut=0, tol=0.01, s=8, nsp=4, ch=0)[0]
    # cmds.setAttr('{0}.sz'.format(shape), 0)
    # cmds.select(shape)
    # cmds.hyperShade(assign=material)
    group = cmds.createNode("transform", name="{0}_grp".format(shape))
    cmds.parent(shape, group)
    cmds.makeIdentity(shape, apply=True)
    cmds.addAttr(shape, longName=MESSAGE_ATTRIBUTE, attributeType="message")
    cmds.connectAttr(
        "{0}.message".format(joint), "{0}.{1}".format(shape, MESSAGE_ATTRIBUTE)
    )
    for attr in ["tx", "ty", "tz", "ry", "rz", "v"]:
        cmds.setAttr("{0}.{1}".format(shape, attr), lock=True, keyable=False)
    return group, shape 
Example #24
Source File: test_cmt_skinio.py    From cmt with MIT License 5 votes vote down vote up
def setUp(self):
        self.joint1 = cmds.joint(p=(-0.5, -0.5, 0))
        self.joint2 = cmds.joint(p=(0, 0.0, 0))
        self.joint3 = cmds.joint(p=(0.5, 0.5, 0))
        self.shape = cmds.polyCube()[0]
        cmds.delete(self.shape, ch=True)
        self.skin = cmds.skinCluster(self.joint1, self.joint2, self.joint3, self.shape)[
            0
        ]
        self.expected = {
            "bindMethod": 1,
            "blendWeights": [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
            "dropoffRate": 4.0,
            "heatmapFalloff": 0.0,
            "maintainMaxInfluences": False,
            "maxInfluences": 2,
            "name": u"skinCluster1",
            "normalizeWeights": 1,
            "shape": u"pCube1",
            "skinningMethod": 0,
            "useComponents": False,
            "weightDistribution": 0,
            "weights": {
                "joint1": [0.9, 0.5, 0.5, 0.0, 0.5, 0.0, 0.9, 0.5],
                "joint2": [
                    0.10000000000000002,
                    0.5,
                    0.5,
                    0.5,
                    0.5,
                    0.5,
                    0.10000000000000002,
                    0.5,
                ],
                "joint3": [0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0],
            },
        } 
Example #25
Source File: dpSuspension.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def createGuide(self, *args):
        Base.StartClass.createGuide(self)
        # Custom GUIDE:
        cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool')
        cmds.setAttr(self.moduleGrp+".flip", 0)
        cmds.addAttr(self.moduleGrp, longName="fatherB", dataType='string')
        
        cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string')
        
        self.cvALoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLocA", r=0.3, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        self.jAGuide = cmds.joint(name=self.guideName+"_jAGuide", radius=0.001)
        cmds.setAttr(self.jAGuide+".template", 1)
        cmds.parent(self.jAGuide, self.moduleGrp, relative=True)
        
        self.cvBLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLocB", r=0.3, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        cmds.parent(self.cvBLoc, self.cvALoc)
        cmds.setAttr(self.cvBLoc+".tz", 3)
        cmds.setAttr(self.cvBLoc+".rotateX", 180)
        self.jBGuide = cmds.joint(name=self.guideName+"_jBGuide", radius=0.001)
        cmds.setAttr(self.jBGuide+".template", 1)
        cmds.transformLimits(self.cvBLoc, tz=(0.01, 1), etz=(True, False))
        self.ctrls.setLockHide([self.cvBLoc], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
        
        cmds.parent(self.cvALoc, self.moduleGrp)
        cmds.parent(self.jBGuide, self.jAGuide)
        cmds.parentConstraint(self.cvALoc, self.jAGuide, maintainOffset=False, name=self.jAGuide+"_ParentConstraint")
        cmds.parentConstraint(self.cvBLoc, self.jBGuide, maintainOffset=False, name=self.jBGuide+"_ParentConstraint")
        cmds.scaleConstraint(self.cvALoc, self.jAGuide, maintainOffset=False, name=self.jAGuide+"_ScaleConstraint")
        cmds.scaleConstraint(self.cvBLoc, self.jBGuide, maintainOffset=False, name=self.jBGuide+"_ScaleConstraint") 
Example #26
Source File: dpSingle.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def createGuide(self, *args):
        Base.StartClass.createGuide(self)
        # Custom GUIDE:
        cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool')
        cmds.setAttr(self.moduleGrp+".flip", 0)
        
        cmds.addAttr(self.moduleGrp, longName="indirectSkin", attributeType='bool')
        cmds.setAttr(self.moduleGrp+".indirectSkin", 0)
        cmds.addAttr(self.moduleGrp, longName='holder', attributeType='bool')
        cmds.setAttr(self.moduleGrp+".holder", 0)
        
        cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string')
        
        self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001)
        cmds.setAttr(self.jGuide1+".template", 1)
        cmds.parent(self.jGuide1, self.moduleGrp, relative=True)
        
        self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        cmds.parent(self.cvEndJoint, self.cvJointLoc)
        cmds.setAttr(self.cvEndJoint+".tz", 1.3)
        self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001)
        cmds.setAttr(self.jGuideEnd+".template", 1)
        cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False))
        self.ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
        
        cmds.parent(self.cvJointLoc, self.moduleGrp)
        cmds.parent(self.jGuideEnd, self.jGuide1)
        cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint")
        cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint")
        cmds.scaleConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ScaleConstraint")
        cmds.scaleConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ScaleConstraint") 
Example #27
Source File: dpSteering.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def createGuide(self, *args):
        Base.StartClass.createGuide(self)
        # Custom GUIDE:
        cmds.addAttr(self.moduleGrp, longName="flip", attributeType='bool')
        cmds.setAttr(self.moduleGrp+".flip", 0)
        
        cmds.setAttr(self.moduleGrp+".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string')
        
        self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName+"_JointLoc1", r=0.3, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        self.jGuide1 = cmds.joint(name=self.guideName+"_JGuide1", radius=0.001)
        cmds.setAttr(self.jGuide1+".template", 1)
        cmds.parent(self.jGuide1, self.moduleGrp, relative=True)
        
        self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName+"_JointEnd", r=0.1, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        cmds.parent(self.cvEndJoint, self.cvJointLoc)
        cmds.setAttr(self.cvEndJoint+".tz", 3)
        self.jGuideEnd = cmds.joint(name=self.guideName+"_JGuideEnd", radius=0.001)
        cmds.setAttr(self.jGuideEnd+".template", 1)
        cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False))
        self.ctrls.setLockHide([self.cvEndJoint], ['tx', 'ty', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz'])
        
        cmds.parent(self.cvJointLoc, self.moduleGrp)
        cmds.parent(self.jGuideEnd, self.jGuide1)
        cmds.parentConstraint(self.cvJointLoc, self.jGuide1, maintainOffset=False, name=self.jGuide1+"_ParentConstraint")
        cmds.parentConstraint(self.cvEndJoint, self.jGuideEnd, maintainOffset=False, name=self.jGuideEnd+"_ParentConstraint")
        
        cmds.setAttr(self.moduleGrp+".translateY", 3)
        cmds.setAttr(self.moduleGrp+".rotateX", 45) 
Example #28
Source File: dpFinger.py    From dpAutoRigSystem with GNU General Public License v2.0 5 votes vote down vote up
def createGuide(self, *args):
        Base.StartClass.createGuide(self)
        # Custom GUIDE:
        cmds.addAttr(self.moduleGrp, longName="nJoints", attributeType='long')
        cmds.setAttr(self.moduleGrp + ".nJoints", 1)

        cmds.setAttr(self.moduleGrp + ".moduleNamespace", self.moduleGrp[:self.moduleGrp.rfind(":")], type='string')

        self.cvJointLoc, shapeSizeCH = self.ctrls.cvJointLoc(ctrlName=self.guideName + "_JointLoc1", r=0.3, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        self.jGuide1 = cmds.joint(name=self.guideName + "_JGuide1", radius=0.001)
        cmds.setAttr(self.jGuide1 + ".template", 1)
        cmds.parent(self.jGuide1, self.moduleGrp, relative=True)

        self.cvEndJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName + "_JointEnd", r=0.2, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        cmds.parent(self.cvEndJoint, self.cvJointLoc)
        cmds.setAttr(self.cvEndJoint + ".tz", 1.3)
        self.jGuideEnd = cmds.joint(name=self.guideName + "_JGuideEnd", radius=0.001)
        cmds.setAttr(self.jGuideEnd + ".template", 1)
        cmds.transformLimits(self.cvEndJoint, tz=(0.01, 1), etz=(True, False))
        self.ctrls.setLockHide([self.cvEndJoint], ['rx', 'ry', 'rz', 'sx', 'sy', 'sz'])

        cmds.parent(self.cvJointLoc, self.moduleGrp)
        cmds.parent(self.jGuideEnd, self.jGuide1)
        self.ctrls.directConnect(self.cvJointLoc, self.jGuide1, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz'])
        self.ctrls.directConnect(self.cvEndJoint, self.jGuideEnd, ['tx', 'ty', 'tz', 'rx', 'ry', 'rz'])

        # change the number of falanges to 3:
        self.changeJointNumber(3)

        # create a base cvLoc to start the finger joints:
        self.cvBaseJoint, shapeSizeCH = self.ctrls.cvLocator(ctrlName=self.guideName + "_JointLoc0", r=0.2, d=1, guide=True)
        self.connectShapeSize(shapeSizeCH)
        cmds.setAttr(self.cvBaseJoint + ".translateZ", -1)
        cmds.parent(self.cvBaseJoint, self.moduleGrp)

        # transform cvLocs in order to put as a good finger guide:
        cmds.setAttr(self.moduleGrp + ".rotateX", 90)
        cmds.setAttr(self.moduleGrp + ".rotateZ", 90) 
Example #29
Source File: create.py    From maya-spline-ik with GNU General Public License v3.0 5 votes vote down vote up
def rootJoint(self):
        """
        :return: name of root joint
        :rtype: str
        """
        return self._rootJoint 
Example #30
Source File: create.py    From maya-spline-ik with GNU General Public License v3.0 5 votes vote down vote up
def __createPointOnCurves(self):
        pocs = []
        aims = []

        for i, parameter in enumerate(self.jParameters):
            # create follicle
            loc, poc, aim = curve.createFollicle(
                "{0}_{1:03d}".format(self.name, i + 1),
                self.curve,
                parameter=parameter,
                upDirection=self.upDirection,
                forwardDirection=self.forwardDirection,
                overrideNormal="{0}.output3D".format(self.ups[i]),
                subtractPositionFromNormal=True
            )

            aims.append(aim)
            pocs.append(poc)

            cmds.parent(aim, world=True)

            # remove locator, will be replaced with joint later
            cmds.delete(loc)

        return pocs, aims
        
    # ------------------------------------------------------------------------