當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.makeIdentity方法代碼示例

本文整理匯總了Python中maya.cmds.makeIdentity方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.makeIdentity方法的具體用法?Python cmds.makeIdentity怎麽用?Python cmds.makeIdentity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.makeIdentity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: setControlDirection

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def setControlDirection(self, cvNode, cvDirection, *args):
        """ Rotate the node given to have the correct direction orientation.
        """
        if cvDirection == "-X":
            cmds.setAttr(cvNode+".rotateX", 90)
            cmds.setAttr(cvNode+".rotateY", -90)
        elif cvDirection == "+X":
            cmds.setAttr(cvNode+".rotateX", -90)
            cmds.setAttr(cvNode+".rotateY", -90)
        elif cvDirection == "-Y":
            cmds.setAttr(cvNode+".rotateZ", 180)
        elif cvDirection == "-Z":
            cmds.setAttr(cvNode+".rotateX", -90)
        elif cvDirection == "+Z":
            cmds.setAttr(cvNode+".rotateX", 90)
        else:
            pass #default +Y, just pass
        cmds.makeIdentity(cvNode, rotate=True, apply=True)
        # rotate and freezeTransformation from given cvRot vector:
        cmds.rotate(self.cvRot[0], self.cvRot[1], self.cvRot[2], self.cvCurve)
        cmds.makeIdentity(self.cvCurve, rotate=True, apply=True) 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:23,代碼來源:dpBaseControlClass.py

示例2: align_with_child

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
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) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:26,代碼來源:orientjoints.py

示例3: combineCurves

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def combineCurves(self, curveList, *args):
        """ Combine all guiven curve to just one main curve and return it.
        """
        mainCurve = curveList[0]
        cmds.makeIdentity(mainCurve, translate=True, rotate=True, scale=True, apply=True)
        for item in curveList[1:]:
            cmds.makeIdentity(item, translate=True, rotate=True, scale=True, apply=True)
            self.ctrls.transferShape(True, False, item, [mainCurve])
        cmds.setAttr(mainCurve+".className", self.guideModuleName, type="string")
        return mainCurve 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:12,代碼來源:dpBaseControlClass.py

示例4: cvJointLoc

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def cvJointLoc(self, ctrlName, r=0.3, d=1, rot=(0, 0, 0), guide=True, *args):
        """Create and return a cvJointLocator curve to be usually used in the guideSystem and the clusterHandle to shapeSize.
        """
        # create locator curve:
        cvLoc = self.cvLocator(ctrlName+"_CvLoc", r, d)
        # create arrow curves:
        cvArrow1 = cmds.curve(n=ctrlName+"_CvArrow1", d=3, p=[(-0.1*r, 0.9*r, 0.2*r), (-0.1*r, 0.9*r, 0.23*r), (-0.1*r, 0.9*r, 0.27*r), (-0.1*r, 0.9*r, 0.29*r), (-0.1*r, 0.9*r, 0.3*r), (-0.372*r, 0.9*r, 0.24*r), (-0.45*r, 0.9*r, -0.13*r), (-0.18*r, 0.9*r, -0.345*r), (-0.17*r, 0.9*r, -0.31*r), (-0.26*r, 0.9*r, -0.41*r), (-0.21*r, 0.9*r, -0.41*r), (-0.05*r, 0.9*r, -0.4*r), (0, 0.9*r, -0.4*r), (-0.029*r, 0.9*r, -0.33*r), (-0.048*r, 0.9*r, -0.22*r), (-0.055*r, 0.9*r, -0.16*r), (-0.15*r, 0.9*r, -0.272*r), (-0.12*r, 0.9*r, -0.27*r), (-0.35*r, 0.9*r, -0.1*r), (-0.29*r, 0.9*r, 0.15*r), (-0.16*r, 0.9*r, 0.21*r), (-0.1*r, 0.9*r, 0.2*r)] )
        cvArrow2 = cmds.curve(n=ctrlName+"_CvArrow2", d=3, p=[(0.1*r, 0.9*r, -0.2*r), (0.1*r, 0.9*r, -0.23*r), (0.1*r, 0.9*r, -0.27*r), (0.1*r, 0.9*r, -0.29*r), (0.1*r, 0.9*r, -0.3*r), (0.372*r, 0.9*r, -0.24*r), (0.45*r, 0.9*r, 0.13*r), (0.18*r, 0.9*r, 0.345*r), (0.17*r, 0.9*r, 0.31*r), (0.26*r, 0.9*r, 0.41*r), (0.21*r, 0.9*r, 0.41*r), (0.05*r, 0.9*r, 0.4*r), (0, 0.9*r, 0.4*r), (0.029*r, 0.9*r, 0.33*r), (0.048*r, 0.9*r, 0.22*r), (0.055*r, 0.9*r, 0.16*r), (0.15*r, 0.9*r, 0.272*r), (0.12*r, 0.9*r, 0.27*r), (0.35*r, 0.9*r, 0.1*r), (0.29*r, 0.9*r, -0.15*r), (0.16*r, 0.9*r, -0.21*r), (0.1*r, 0.9*r, -0.2*r)] )
        cvArrow3 = cmds.curve(n=ctrlName+"_CvArrow3", d=3, p=[(-0.1*r, -0.9*r, 0.2*r), (-0.1*r, -0.9*r, 0.23*r), (-0.1*r, -0.9*r, 0.27*r), (-0.1*r, -0.9*r, 0.29*r), (-0.1*r, -0.9*r, 0.3*r), (-0.372*r, -0.9*r, 0.24*r), (-0.45*r, -0.9*r, -0.13*r), (-0.18*r, -0.9*r, -0.345*r), (-0.17*r, -0.9*r, -0.31*r), (-0.26*r, -0.9*r, -0.41*r), (-0.21*r, -0.9*r, -0.41*r), (-0.05*r, -0.9*r, -0.4*r), (0, -0.9*r, -0.4*r), (-0.029*r, -0.9*r, -0.33*r), (-0.048*r, -0.9*r, -0.22*r), (-0.055*r, -0.9*r, -0.16*r), (-0.15*r, -0.9*r, -0.272*r), (-0.12*r, -0.9*r, -0.27*r), (-0.35*r, -0.9*r, -0.1*r), (-0.29*r, -0.9*r, 0.15*r), (-0.16*r, -0.9*r, 0.21*r), (-0.1*r, -0.9*r, 0.2*r)] )
        cvArrow4 = cmds.curve(n=ctrlName+"_CvArrow4", d=3, p=[(0.1*r, -0.9*r, -0.2*r), (0.1*r, -0.9*r, -0.23*r), (0.1*r, -0.9*r, -0.27*r), (0.1*r, -0.9*r, -0.29*r), (0.1*r, -0.9*r, -0.3*r), (0.372*r, -0.9*r, -0.24*r), (0.45*r, -0.9*r, 0.13*r), (0.18*r, -0.9*r, 0.345*r), (0.17*r, -0.9*r, 0.31*r), (0.26*r, -0.9*r, 0.41*r), (0.21*r, -0.9*r, 0.41*r), (0.05*r, -0.9*r, 0.4*r), (0, -0.9*r, 0.4*r), (0.029*r, -0.9*r, 0.33*r), (0.048*r, -0.9*r, 0.22*r), (0.055*r, -0.9*r, 0.16*r), (0.15*r, -0.9*r, 0.272*r), (0.12*r, -0.9*r, 0.27*r), (0.35*r, -0.9*r, 0.1*r), (0.29*r, -0.9*r, -0.15*r), (0.16*r, -0.9*r, -0.21*r), (0.1*r, -0.9*r, -0.2*r)] )
        cvArrow5 = cmds.curve(n=ctrlName+"_CvArrow5", d=1, p=[(0, 0, 1.2*r), (0.09*r, 0, 1*r), (-0.09*r, 0, 1*r), (0, 0, 1.2*r)] )
        cvArrow6 = cmds.curve(n=ctrlName+"_CvArrow6", d=1, p=[(0, 0, 1.2*r), (0, 0.09*r, 1*r), (0, -0.09*r, 1*r), (0, 0, 1.2*r)] )
        # rename curveShape:
        locArrowList = [cvLoc, cvArrow1, cvArrow2, cvArrow3, cvArrow4, cvArrow5, cvArrow6]
        self.renameShape(locArrowList)
        # create ball curve:
        cvTemplateBall = self.cvControl("Ball", ctrlName+"_CvBall", r=0.7*r, d=3)
        # parent shapes to transform:
        locCtrl = cmds.group(name=ctrlName, empty=True)
        ballChildrenList = cmds.listRelatives(cvTemplateBall, shapes=True, children=True)
        for ballChildren in ballChildrenList:
            cmds.setAttr(ballChildren+".template", 1)
        self.transferShape(True, False, cvTemplateBall, [locCtrl])
        for transform in locArrowList:
            self.transferShape(True, False, transform, [locCtrl])
        # set rotation direction:
        cmds.setAttr(locCtrl+".rotateX", rot[0])
        cmds.setAttr(locCtrl+".rotateY", rot[1])
        cmds.setAttr(locCtrl+".rotateZ", rot[2])
        cmds.makeIdentity(locCtrl, rotate=True, apply=True)
        # create an attribute to be used as guide by module:
        cmds.addAttr(locCtrl, longName="nJoint", attributeType='long')
        cmds.setAttr(locCtrl+".nJoint", 1)
        # colorize curveShapes:
        self.colorShape([locCtrl], 'blue')
        # shapeSize setup:
        shapeSizeCluster = self.shapeSizeSetup(locCtrl)
        cmds.select(clear=True)
        return [locCtrl, shapeSizeCluster] 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:41,代碼來源:dpControls.py

示例5: setAndFreeze

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def setAndFreeze(nodeName="", tx=None, ty=None, tz=None, rx=None, ry=None, rz=None, sx=None, sy=None, sz=None, freeze=True):
        """This function set attribute values and do a freezeTransfomation.
        """
        if nodeName != "":
            attrNameList  = ['tx', 'ty', 'tz', 'rx', 'ry', 'rz', 'sx', 'sy', 'sz']
            attrValueList = [tx, ty, tz, rx, ry, rz, sx, sy, sz]
            # setting attribute values:
            for v, attrValue in enumerate(attrValueList):
                if attrValue:
                    try:
                        cmds.setAttr(nodeName+'.'+attrNameList[v], attrValue)
                    except:
                        pass
            # looking the need of freeze:
            if freeze:
                freezeT = False
                freezeR = False
                freezeS = False
                if tx != None or ty != None or tz != None:
                    freezeT = True
                if rx != None or ry != None or rz != None:
                    freezeR = True
                if sx != None or sy != None or sz != None:
                    freezeS = True
                try:
                    cmds.makeIdentity(nodeName, apply=freeze, translate=freezeT, rotate=freezeR, scale=freezeS)
                except:
                    pass 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:30,代碼來源:dpControls.py

示例6: __createSlideControls

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def __createSlideControls(self):
        # variables
        offsets = []
        controls = []
        
        # loop controls
        for suffix in ["slide", "slide_min", "slide_max"]:
            ctrlOffset, ctrl = control.createControlShape(
                "{0}_{1}".format(self.name, suffix),
                self.slideControlShape,
                self.slideControlColour
            )
            
            # scale constraint
            cmds.scaleConstraint(self.rootControl, ctrlOffset)

            # append to list
            offsets.append(ctrlOffset)
            controls.append(ctrl)
            
        # scale controls
        scale = [0.75, 0.5, 0.5]
        for ctrl, s in zip(controls, scale):
            cmds.setAttr("{0}.scale".format(ctrl), s, s, s)
            cmds.makeIdentity(ctrl, apply=True, scale=True)
        
        # parent controls
        cmds.parent(
            offsets,
            self.rootControl
        )

        return controls 
開發者ID:robertjoosten,項目名稱:maya-spline-ik,代碼行數:35,代碼來源:create.py

示例7: emit

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def emit(self, *args):
        """ run the actual sample command and check if transforms are frozen """

        # exit spore context since it looses track of points after sampling
        if cmds.currentCtx().startswith('spore'):
            cmds.setToolTo('selectSuperContext')

        in_mesh = node_utils.get_connected_in_mesh(self._node)
        transform = cmds.listRelatives(in_mesh, p=True, f=True)[0]
        if cmds.getAttr(transform + '.translateX') != 0\
        or cmds.getAttr(transform + '.translateY') != 0\
        or cmds.getAttr(transform + '.translateZ') != 0\
        or cmds.getAttr(transform + '.rotateX') != 0\
        or cmds.getAttr(transform + '.rotateY') != 0\
        or cmds.getAttr(transform + '.rotateZ') != 0\
        or cmds.getAttr(transform + '.scaleX') != 1\
        or cmds.getAttr(transform + '.scaleY') != 1\
        or cmds.getAttr(transform + '.scaleZ') != 1:
            msg = 'Feeze transformations to sample the geomety!'
            result = message_utils.IOHandler().confirm_dialog(msg, 'Freeze Transformations')
            if result:
                cmds.makeIdentity(transform, a=True, s=True, r=True, t=True, n=0)
            else:
                return

        cmds.setAttr('{}.emit'.format(self._node), 1)
        cmds.sporeSampleCmd()

    # ------------------------------------------------------------------------ #
    # clear button
    # ------------------------------------------------------------------------ # 
開發者ID:wiremas,項目名稱:spore,代碼行數:33,代碼來源:AEsporeNodeTemplate.py

示例8: fix

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def fix(self, report, params):
        cmds.makeIdentity(report.node().name(), apply=True, t=True, r=True, s=True)

        return True 
開發者ID:sol-ansano-kim,項目名稱:medic,代碼行數:6,代碼來源:unFrozenTransforms.py

示例9: freezeAll

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def freezeAll():
    cmds.makeIdentity(apply=True, t=True, r=True, s=True, n=False) 
開發者ID:minoue,項目名稱:rush,代碼行數:4,代碼來源:Modify.py

示例10: freezeOnlyTranslation

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def freezeOnlyTranslation():
    cmds.makeIdentity(apply=True, t=True, r=False, s=False, n=False) 
開發者ID:minoue,項目名稱:rush,代碼行數:4,代碼來源:Modify.py

示例11: freezeOnlyRotation

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def freezeOnlyRotation():
    cmds.makeIdentity(apply=True, t=False, r=True, s=False, n=False)


# Snap align 
開發者ID:minoue,項目名稱:rush,代碼行數:7,代碼來源:Modify.py

示例12: freezeOnlyScale

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def freezeOnlyScale():
    cmds.makeIdentity(apply=True, t=False, r=False, s=True, n=False)


# Conversions 
開發者ID:minoue,項目名稱:rush,代碼行數:7,代碼來源:Modify.py

示例13: make_planar

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
def make_planar(joints):
    for joint in joints:
        parent = cmds.listRelatives(joint, parent=True, path=True)
        if not parent:
            log.warning(
                "Cannot make %s planar because it does not have a parent.", joint
            )
            continue
        children = _unparent_children(joint)
        if not children:
            log.warning(
                "Cannot make %s planar because it does not have any children.", joint
            )
            continue
        cmds.delete(
            cmds.aimConstraint(
                children[0],
                joint,
                aim=(1, 0, 0),
                u=(0, 1, 0),
                worldUpType="object",
                worldUpObject=parent[0],
            )
        )
        cmds.makeIdentity(joint, apply=True)
        _reparent_children(joint, children)

    if joints:
        cmds.select(joints) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:31,代碼來源:orientjoints.py

示例14: template_joints

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [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

示例15: create_orient_manipulator

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import makeIdentity [as 別名]
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 
開發者ID:chadmv,項目名稱:cmt,代碼行數:39,代碼來源:orientjoints.py


注:本文中的maya.cmds.makeIdentity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。