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


Python cmds.rotate方法代碼示例

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


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

示例1: setControlDirection

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

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def createElbowCtrl(self, myName='Limb_Ctrl', zero=True, armStyle=True, *args):
        """ Create the Ribbon Corner (Elbow) control.
            Returns the group, the control curve and it's zeroOut group.
        """
        if armStyle:
            curve = self.ctrls.cvControl("id_039_RibbonCorner", myName, r=self.ctrlRadius, d=self.curveDegree, rot=(0, 90, 0))
        else:
            curve = self.ctrls.cvControl("id_039_RibbonCorner", myName, r=self.ctrlRadius, d=self.curveDegree, rot=(90, 0, 0))
        grp = None
        if zero:
            zero = cmds.group(curve, n=myName+'_Zero')
            grp = cmds.group(zero, n=myName+'_Grp')
            if armStyle:
                cmds.rotate(0, -90, -90, zero)
            else:
                cmds.rotate(-90, 0, -90, zero)
        cmds.addAttr(curve, longName='autoBend', attributeType='float', minValue=0, maxValue=1, defaultValue=0, keyable=True)
        cmds.addAttr(curve, longName='pin', attributeType='float', minValue=0, maxValue=1, defaultValue=0, keyable=True)
        self.dpUIinst.ctrls.setLockHide([curve], ['sx', 'sy', 'sz', 'v'])
        return [grp, curve, zero] 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:22,代碼來源:jcRibbon.py

示例3: combineCurves

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

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def set_joint_orient(reset=True):
    from . import sisidebar_sub
    joints = cmds.ls(sl=True, type='joint')

    if len(joints) == 0:
        confirm_mes = lang.Lang(
            en='Joint is not selected\nDo you want to process all the joints in the scene? ',
            ja=u'ジョイントが選択されていません\nシーン內のすべてのジョイントを処理しますか?'
        )
        rtn = pm.cmds.confirmDialog(title='Confirm', message=confirm_mes.output(), button=['Yes', 'No'], defaultButton='Yes',
                              cancelButton='No', dismissString='No')
        if rtn != 'Yes':
            return False

        joints = cmds.ls('*', type='joint')
        if len(joints) == 0:
            pm.confirmDialog(title='Warning', message='Joint Object Nothing.', button='OK', icon='Warning')
            return False

    for j in joints:
        # マトリックス取得
        mat = cmds.xform(j, q=True, m=True)
        # 回転とジョイントの方向をいったん0に
        cmds.rotate(0, 0, 0, j, objectSpace=True)
        cmds.joint(j, e=True, orientation=[0, 0, 0])
        # マトリックス再設定、回転のみに數値が入る。
        cmds.xform(j, m=mat)

        if reset:
            # 回転取得
            rot = cmds.xform(j, q=True, ro=True)
            # 回転を0にしてジョイントの方向に同じ値を移す
            cmds.rotate(0, 0, 0, j, objectSpace=True)
            cmds.joint(j, e=True, orientation=rot)
    sisidebar_sub.get_matrix() 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:37,代碼來源:transform.py

示例5: trs_matching

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def trs_matching(node=None, sel_org=True):
    global matching_obj
    global matching_mode
    global child_comp_flag
    #print matching_mode, matching_obj
    mode = matching_mode
    if node is None:
        mached_obj = cmds.ls(sl=True, l=True, type='transform')
    else:
        #print 'muched obj', node
        mached_obj = node
    if not mached_obj:
        if sel_org:
            finish_matching()
        return
    else:
        if isinstance(mached_obj, list):
            mached_obj = mached_obj[0]
    #print 'trs matching :', mached_obj
    scl = cmds.xform(mached_obj, q=True, s=True, ws=True)
    rot = cmds.xform(mached_obj, q=True, ro=True, ws=True)
    pos = cmds.xform(mached_obj, q=True, t=True, ws=True)
    for obj in matching_obj:
        if mode == 'scale' or mode == 'all':
            cmds.scale(1.0, 1.0, 1.0, obj, pcp=True)
            ws_scl = cmds.xform(obj, q=True, s=True, ws=True)
            cmds.scale(scl[0]/ws_scl[0], scl[1]/ws_scl[1], scl[2]/ws_scl[2], obj, pcp=child_comp_flag)
        if mode == 'rotate' or mode == 'all':
            cmds.rotate(rot[0], rot[1], rot[2], obj, ws=True, pcp=child_comp_flag)
        if mode == 'translate' or mode == 'all':
            cmds.move(pos[0], pos[1], pos[2], obj, ws=True, pcp=child_comp_flag)
    if sel_org:
        finish_matching()
    
#アトリビュートの桁數を丸める 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:37,代碼來源:transform.py

示例6: round_transform

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def round_transform(mode='', digit=3):
    from . import sisidebar_sub
    sel = cmds.ls(sl=True, l=True)

    axis = ['X', 'Y', 'Z']
    if mode == 'all':
        mode_list = ['.translate', '.rotate', '.scale', '.jointOrient']
    else:
        mode_list = ['.' + mode]
    for s in sel:
        for a, m in itertools.product(axis, mode_list):
            #print cmds.nodeType(s) , m
            #print cmds.nodeType(s) != 'joint'
            if cmds.nodeType(s) != 'joint' and m == '.jointOrient':
                #print m == '.jointOrient'
                #print 'Node Type Error'
                continue
            try:
                v = cmds.getAttr(s+m+a)
                #print v
                v = round(v, digit)
                cmds.setAttr(s+m+a, v)
                #print v
            except Exception as e:
                print e.message
    sisidebar_sub.get_matrix() 
開發者ID:ShikouYamaue,項目名稱:SISideBar,代碼行數:28,代碼來源:transform.py

示例7: setRotation

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def setRotation(self, x=None, y=None, z=None):
        self._doTransform(cmds.rotate, x, y, z) 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:4,代碼來源:mayaSphere4.py

示例8: setRotation

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def setRotation(self, x=None, y=None, z=None):
        
        for name in ('x','y','z'):
            val = locals()[name]
            if val is not None:
                opts = {name:True, 'objectSpace':True, 'absolute':True}
                cmds.rotate(val, self.name, **opts) 
開發者ID:justinfx,項目名稱:tutorials,代碼行數:9,代碼來源:mayaSphere3.py

示例9: rotate_components

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def rotate_components(rx, ry, rz, nodes=None):
    """Rotate the given nodes' components the given number of degrees about each axis.

    :param rx: Degrees around x.
    :param ry: Degrees around y.
    :param rz: Degrees around z.
    :param nodes: Optional list of curves.
    """
    if nodes is None:
        nodes = cmds.ls(sl=True) or []
    for node in nodes:
        pivot = cmds.xform(node, q=True, rp=True, ws=True)
        cmds.rotate(
            rx, ry, rz, "{0}.cv[*]".format(node), r=True, p=pivot, os=True, fo=True
        ) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:17,代碼來源:control.py

示例10: createFollicles

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import rotate [as 別名]
def createFollicles(self, rib, num, pad=0.5, name='xxxx', horizontal=False, side=0, jointLabelAdd=0, jointLabelName="RibbonName", *args): 
        """ Create follicles to be used by the Ribbon system.
            Returns a list with joints and follicles created.
        """
        #define variables
        jnts = []
        fols = []
        #create joints and follicles based in the choose options from user
        if horizontal:
            #calcule the position of the first follicle
            passo = (1/float(num))/2.0;
            for i in range(num):
                #create the follicle and do correct connections to link it to the 
                folShape = cmds.createNode('follicle', name=name+'_%02d_FolShape'%i)
                folTrans = cmds.rename(cmds.listRelatives(folShape, p=1)[0], name+'_%02d_Fol'%i)         
                fols.append(folTrans)
                cmds.connectAttr(rib+'.worldMatrix[0]', folShape+'.inputWorldMatrix')
                cmds.connectAttr(rib+'.local', folShape+'.inputSurface')
                cmds.connectAttr(folShape+'.outTranslate', folTrans+'.translate')
                cmds.connectAttr(folShape+'.outRotate', folTrans+'.rotate')
                cmds.setAttr(folShape+'.parameterU', passo)
                cmds.setAttr(folShape+'.parameterV', 0.5) 
                #create the joint in the follicle
                cmds.select(cl=True)
                jnts.append(cmds.joint(n=name+'_%02d_Jnt'%i))
                cmds.setAttr(jnts[i]+'.jointOrient', 0, 0, 0)
                utils.setJointLabel(name+'_%02d_Jnt'%i, side+jointLabelAdd, 18, jointLabelName+'_%02d'%i)
                cmds.select(cl=True)
                #calculate the position of the first follicle
                passo+=(1/float(num))
            results = [jnts, fols]
            #return the joints and follicles created
        else:
            #calculate the position of the first follicle
            passo = (1/float(num))/2.0;
            for i in range(num):
                #create the follicle and do correct connections in order to link it to the ribbon
                folShape = cmds.createNode('follicle', name=name+'_%02d_FolShape'%i)
                folTrans = cmds.rename(cmds.listRelatives(folShape, p=1)[0], name+'_%02d_Fol'%i)
                fols.append(folTrans)
                cmds.connectAttr(rib+'.worldMatrix[0]', folShape+'.inputWorldMatrix')
                cmds.connectAttr(rib+'.local', folShape+'.inputSurface')
                cmds.connectAttr(folShape+'.outTranslate', folTrans+'.translate')
                cmds.connectAttr(folShape+'.outRotate', folTrans+'.rotate')
                cmds.setAttr(folShape+'.parameterU', 0.5)   
                cmds.setAttr(folShape+'.parameterV', passo) 
                #create the joint in the follicle
                cmds.select(cl=True)
                jnts.append(cmds.joint(n=name+'_%02d_Jnt'%i))
                cmds.setAttr(jnts[i]+'.jointOrient', 0, 0, 0)
                utils.setJointLabel(name+'_%02d_Jnt'%i, side+jointLabelAdd, 18, jointLabelName+'_%02d'%i)
                cmds.select(cl=True)
                #calculate the first follicle position
                passo+=(1/float(num))
            results = [jnts, fols]
        #return the created joints and follicles
        cmds.parent(fols, rib)
        return results 
開發者ID:nilouco,項目名稱:dpAutoRigSystem,代碼行數:60,代碼來源:jcRibbon.py


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