Python maya.cmds.rotate() Examples
The following are 10
code examples of maya.cmds.rotate().
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: dpBaseControlClass.py From dpAutoRigSystem with GNU General Public License v2.0 | 7 votes |
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)
Example #2
Source File: jcRibbon.py From dpAutoRigSystem with GNU General Public License v2.0 | 6 votes |
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]
Example #3
Source File: transform.py From SISideBar with MIT License | 5 votes |
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()
Example #4
Source File: transform.py From SISideBar with MIT License | 5 votes |
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() #アトリビュートの桁数を丸める
Example #5
Source File: transform.py From SISideBar with MIT License | 5 votes |
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()
Example #6
Source File: mayaSphere4.py From tutorials with MIT License | 5 votes |
def setRotation(self, x=None, y=None, z=None): self._doTransform(cmds.rotate, x, y, z)
Example #7
Source File: mayaSphere3.py From tutorials with MIT License | 5 votes |
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)
Example #8
Source File: control.py From cmt with MIT License | 5 votes |
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 )
Example #9
Source File: dpBaseControlClass.py From dpAutoRigSystem with GNU General Public License v2.0 | 4 votes |
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
Example #10
Source File: jcRibbon.py From dpAutoRigSystem with GNU General Public License v2.0 | 4 votes |
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