本文整理汇总了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)
示例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]
示例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
示例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()
示例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()
#アトリビュートの桁数を丸める
示例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()
示例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)
示例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)
示例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
)
示例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