当前位置: 首页>>代码示例>>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;未经允许,请勿转载。