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


Python cmds.parentConstraint方法代码示例

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


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

示例1: dpIsolate

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

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
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 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:26,代码来源:dpEye.py

示例3: snap

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def snap(node, snapTo):

    #duplicate the node we want snap
    dup = mc.duplicate(node, parentOnly=True)[0]
    #unlock translates and rotates
    for a in ('.t','.r'):
        for b in 'xyz':
            mc.setAttr(dup+a+b, lock=False)

    mc.parentConstraint(snapTo, dup)

    for a in ('.t','.r'):
        for b in ('x','y','z'):
            try:
                mc.setAttr(node+a+b, mc.getAttr(dup+a+b))
            except StandardError:
                pass

    mc.delete(dup) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:21,代码来源:ml_puppet.py

示例4: createGuide

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
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") 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:33,代码来源:dpSuspension.py

示例5: createGuide

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
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") 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:32,代码来源:dpFkLine.py

示例6: createGuide

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
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") 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:36,代码来源:dpSingle.py

示例7: createGuide

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
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) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:32,代码来源:dpSteering.py

示例8: __connectJoints

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def __connectJoints(self):
        # constraint root
        cmds.parentConstraint(self.rootControl, self.rootJoint, mo=False)
        cmds.scaleConstraint(self.rootControl, self.rootJoint, mo=False)

        # constraint joints
        self.__connectTranslateJoints()
        self.__connectRotateJoints()

        return self.__scaleConstraintJoints()
        
    # ------------------------------------------------------------------------ 
开发者ID:robertjoosten,项目名称:maya-spline-ik,代码行数:14,代码来源:create.py

示例9: template_joints

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
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) 
开发者ID:chadmv,项目名称:cmt,代码行数:36,代码来源:orientjoints.py

示例10: bakeCenterOfMass

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def bakeCenterOfMass(*args):
    '''
    Bake root animation to center of mass.
    '''

    sel = mc.ls(sl=True)

    if not len(sel) == 1:
        raise RuntimeError('Please select the root control of your puppet.')

    root, com = getRootAndCOM(sel[0])

    if not root:
        root = sel[0]
    if not com:
        com = createCenterOfMass()

    start, end = utl.frameRange()
    with utl.IsolateViews():
        mc.bakeResults(com, time=(start,end), sampleBy=1, attribute=['tx','ty','tz'], simulation=True)

    rootOffset = mc.group(em=True, name='rootOffset')
    rootOffset = mc.parent(rootOffset, com)[0]

    #bake
    utl.matchBake(source=[root],
                  destination=[rootOffset],
                  bakeOnOnes=True,
                  maintainOffset=False,
                  preserveTangentWeight=False,
                  translate=True,
                  rotate=True)

    mc.cutKey(root, attribute=['tx','ty','tz','rx','ry','rz'])
    mc.parentConstraint(rootOffset, root)

    mc.select(com) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:39,代码来源:ml_centerOfMass.py

示例11: constrain

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def constrain(source, destination, translate=True, rotate=True, scale=False, maintainOffset=False):
    '''
    Constrain two objects, even if they have some locked attributes.
    '''

    transAttr = None
    rotAttr = None
    scaleAttr = None

    if translate:
        transAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='translate*')
    if rotate:
        rotAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='rotate*')
    if scale:
        scaleAttr = mc.listAttr(destination, keyable=True, unlocked=True, string='scale*')

    rotSkip = list()
    transSkip = list()

    for axis in ['x','y','z']:
        if transAttr and not 'translate'+axis.upper() in transAttr:
            transSkip.append(axis)
        if rotAttr and not 'rotate'+axis.upper() in rotAttr:
            rotSkip.append(axis)

    if not transSkip:
        transSkip = 'none'
    if not rotSkip:
        rotSkip = 'none'

    constraints = list()
    if rotAttr and transAttr and rotSkip == 'none' and transSkip == 'none':
        constraints.append(mc.parentConstraint(source, destination, maintainOffset=maintainOffset))
    else:
        if transAttr:
            constraints.append(mc.pointConstraint(source, destination, skip=transSkip, maintainOffset=maintainOffset))
        if rotAttr:
            constraints.append(mc.orientConstraint(source, destination, skip=rotSkip, maintainOffset=maintainOffset))

    return constraints 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:42,代码来源:ml_utilities.py

示例12: dpDoAddHandFollow

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def dpDoAddHandFollow(self, *args):
        """ Set attributes and call setDrivenKey method.
        """
        sideList = [self.langDic[self.langName]['p002_left'], self.langDic[self.langName]['p003_right']]
        for side in sideList:
            armWristIkCtrl = side+"_"+self.langDic[self.langName]['c037_arm']+"_"+self.langDic[self.langName]['c004_arm_extrem']+"_Ik_Ctrl"
            
            if cmds.objExists(armWristIkCtrl):
                if cmds.objExists(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow']):
                    return
                else:
                    cmds.addAttr(armWristIkCtrl, ln=self.langDic[self.langName]['c032_follow'], at="enum", en=self.defaultName+":"+self.globalName+":"+self.rootName+":"+self.hipsName+":"+self.headName+":")
                    cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], edit=True, keyable=True)
                    
                    parentConst = cmds.parentConstraint(self.spineChestACtrl, self.globalCtrl, self.rootCtrl, self.spineHipsBCtrl, self.headCtrl, armWristIkCtrl+"_Orient_Grp", mo=True, name=armWristIkCtrl+"_Orient_Grp_ParentConstraint")
                    
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.globalCtrl+"W1", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.rootCtrl+"W2", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineHipsBCtrl+"W3", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.headCtrl+"W4", 0)
                    self.dpSetHandFollowSDK(armWristIkCtrl)

                    cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 1)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineChestACtrl+"W0", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.globalCtrl+"W1", 1)
                    self.dpSetHandFollowSDK(armWristIkCtrl)

                    cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 2)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.globalCtrl+"W1", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.rootCtrl+"W2", 1)
                    self.dpSetHandFollowSDK(armWristIkCtrl)

                    cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 3)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.rootCtrl+"W2", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineHipsBCtrl+"W3", 1)
                    self.dpSetHandFollowSDK(armWristIkCtrl)

                    cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 4)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.spineHipsBCtrl+"W3", 0)
                    cmds.setAttr(armWristIkCtrl+"_Orient_Grp_ParentConstraint."+self.headCtrl+"W4", 1)
                    self.dpSetHandFollowSDK(armWristIkCtrl)
                    
                    cmds.setAttr(armWristIkCtrl+"."+self.langDic[self.langName]['c032_follow'], 0) 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:45,代码来源:dpAddHandFollow.py

示例13: matchBakeLocators

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def matchBakeLocators(parent=None, bakeOnOnes=False, constrainSource=False):

    #get neccesary nodes
    objs = mc.ls(sl=True)
    if not objs:
        OpenMaya.MGlobal.displayWarning('Select an Object')
        return

    locs = list()
    cutIndex = dict()
    noKeys = list()
    noKeysLoc = list()

    for obj in objs:


        name = mc.ls(obj, shortNames=True)[0]
        if ':' in name:
            name = obj.rpartition(':')[-1]

        locator = mc.spaceLocator(name='worldBake_'+name+'_#')[0]
        mc.setAttr(locator+'.rotateOrder', 3)


        mc.addAttr(locator, longName='ml_bakeSource', attributeType='message')
        mc.connectAttr('.'.join((obj,'message')), '.'.join((locator,'ml_bakeSource')))
        mc.addAttr(locator, longName='ml_bakeSourceName', dataType='string')
        mc.setAttr('.'.join((locator,'ml_bakeSourceName')), name, type='string')

        if parent:
            locator = mc.parent(locator, parent)[0]

        locs.append(locator)

        #should look through all trans and rot
        if not mc.keyframe(obj, query=True, name=True):
            noKeys.append(obj)
            noKeysLoc.append(locator)

    utl.matchBake(objs, locs, bakeOnOnes=bakeOnOnes)

    if not bakeOnOnes and noKeys:
        utl.matchBake(noKeys, noKeysLoc, bakeOnOnes=True)

    if constrainSource:
        mc.cutKey(objs)
        for loc, obj in zip(locs, objs):
            mc.parentConstraint(loc, obj) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:50,代码来源:ml_worldBake.py

示例14: bakeRoot

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def bakeRoot(*args):
    '''
    Transfer previously baked animation back to the root.
    '''

    sel = mc.ls(sl=True)

    if not len(sel) == 1:
        raise RuntimeError('Please select the root control or COM locator.')

    root, com = getRootAndCOM(sel[0])

    if not root or not com:
        raise RuntimeError('Could not determine root, please ensure that a COM bake setups has been previously run.')

    parCon = mc.listConnections(root, source=True, destination=True, type='parentConstraint')
    if not parCon:
        raise RuntimeError('Root is not constrained, transfer anim to COM node first.')

    src = mc.listConnections(parCon[0]+'.target[0].targetParentMatrix', source=True, destination=False)

    mc.delete(parCon)

    utl.matchBake(source=[src[0]],
                  destination=[root],
                  bakeOnOnes=True,
                  maintainOffset=False,
                  preserveTangentWeight=False,
                  translate=True,
                  rotate=True)

    for kid in mc.listRelatives(com, pa=True):
        if kid.split('|')[-1] == 'rootOffset':
            mc.delete(kid)
            break

    #reconnect constraint
    con = mc.listRelatives(com, type='pointConstraint', pa=True)
    if con:
        mc.cutKey(com)
        for a in 'XYZ':
            mc.connectAttr(con[0]+'.constraintTranslate'+a, com+'.translate'+a) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:44,代码来源:ml_centerOfMass.py

示例15: addMarksToScene

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import parentConstraint [as 别名]
def addMarksToScene(marks):
    '''
    This is temp and will possibly be rolled into future releases.
    '''

    start,end = utl.frameRange()
    camera = utl.getCurrentCamera()
    camShape = mc.listRelatives(camera, shapes=True)[0]
    aov = mc.getAttr(camShape+'.horizontalFilmAperture')

    name = 'ml_stopwatch_'

    numStopwatches = len(mc.ls(name+'*', type='locator'))
    top = mc.spaceLocator(name=name+'#')

    ename = ':'.join([str(x) for x in marks])
    mc.addAttr(top, longName='keyTimes', at='enum', enumName=ename, keyable=True)

    markRange = float(marks[-1]-marks[0])
    viewWidth = aov*2
    viewHeight = -0.4*aov+(numStopwatches*aov*0.08)
    depth = 5

    for mark in marks[1:-1]:

        ann = mc.annotate(top, text=str(mark))
        mc.setAttr(ann+'.displayArrow', 0)

        #parent
        annT = mc.parent(mc.listRelatives(ann, parent=True, path=True), top)[0]
        annT = mc.rename(annT, 'mark_'+str(round(mark)))
        ann = mc.listRelatives(annT, shapes=True, path=True)[0]

        #set the position
        normalX = float(mark-marks[0])/markRange-0.5
        mc.setAttr(annT+'.translateX', viewWidth*normalX*2)
        mc.setAttr(annT+'.translateY', viewHeight)
        mc.setAttr(annT+'.translateZ', -depth)

        #keyframe for color
        mc.setAttr(ann+'.overrideEnabled', 1)

        mc.setKeyframe(ann, attribute='overrideColor', value=17, time=(int(marks[0]-1),int(mark+1)))
        mc.setKeyframe(ann, attribute='overrideColor', value=13, time=(int(mark),))
        mc.keyTangent(ann+'.overrideColor', ott='step')


    mc.select(clear=True)
    mc.parentConstraint(camera, top) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:51,代码来源:ml_stopwatch.py


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