本文整理汇总了Python中maya.cmds.scale方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.scale方法的具体用法?Python cmds.scale怎么用?Python cmds.scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.cmds
的用法示例。
在下文中一共展示了cmds.scale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset_transform
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [as 别名]
def reset_transform(mode='', c_comp=False, reset_pivot=True):
#print 'comp mode :', c_comp
from . import sisidebar_sub
if cmds.selectMode(q=True, co=True):
return
selections = cmds.ls(sl=True, l=True)
#子供のノード退避用ダミーペアレントを用意
dummy = common.TemporaryReparent().main(mode='create')
for sel in selections:
if c_comp:
common.TemporaryReparent().main(sel, dummyParent=dummy, mode='cut')
if mode == 'all':
cmds.xform(sel, t=[0, 0, 0])
cmds.xform(sel, ro=[0, 0, 0])
cmds.xform(sel, s=[1, 1, 1])
if mode == 'trans':
cmds.xform(sel, t=[0, 0, 0])
if mode == 'rot':
cmds.xform(sel, ro=[0, 0, 0])
if mode == 'scale':
cmds.xform(sel, s=[1, 1, 1])
if mode == 'trans' or mode =='all':
if reset_pivot:
cmds.xform(sel+'.scalePivot', t=[0, 0, 0], os=True)
cmds.xform(sel+'.rotatePivot', t=[0, 0, 0], os=True)
if c_comp:
common.TemporaryReparent().main(sel, dummyParent=dummy, mode='parent')
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#ダミー親削除
cmds.select(selections, r=True)
sisidebar_sub.get_matrix()
#フリーズスケーリングをまとめて
示例2: trs_matching
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [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()
#アトリビュートの桁数を丸める
示例3: round_transform
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [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()
示例4: getScale
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [as 别名]
def getScale(self):
return cmds.xform(self.name, query=True, scale=True)
示例5: setScale
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [as 别名]
def setScale(self, x=None, y=None, z=None):
self._doTransform(cmds.scale, x, y, z)
示例6: setScale
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [as 别名]
def setScale(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.scale(val, self.name, **opts)
示例7: freeze_transform
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [as 别名]
def freeze_transform(mode='', c_comp=False):
from . import sisidebar_sub
selections = cmds.ls(sl=True, l=True, tr=True)
#下からのマルチ選択でも正しく上からフリーズできるように階層深さでソート
sel_depth = [[sel, check_depth(sel)] for sel in selections]
sel_depth = sorted(sel_depth, key=lambda a:a[1])
for sel in sel_depth:
sel = sel[0]
dummy = common.TemporaryReparent().main(mode='create')
srt_dummy = common.TemporaryReparent().main(mode='create')
#common.TemporaryReparent().main(sel, dummyParent=dummy, mode='cut')
if not c_comp:
set_maching(nodes=srt_dummy, mode='all', pre_sel=selections)
matching_obj=srt_dummy
trs_matching(node=sel, sel_org=False)
common.TemporaryReparent().main(sel,dummyParent=dummy, srtDummyParent=srt_dummy, mode='custom_cut', preSelection=selections)
attr_lock_flag_list = check_attr_locked(sel)
try:
if mode == 'all':
cmds.makeIdentity(sel, n=0, s=1, r=1, jointOrient=1, t=1, apply=True, pn=1)
cmds.xform(srt_dummy, t=[0, 0, 0])
cmds.xform(srt_dummy, ro=[0, 0, 0])
cmds.xform(srt_dummy, s=[1, 1, 1])
if mode == 'trans':
cmds.makeIdentity(sel, n=0, s=0, r=0, jointOrient=0, t=1, apply=True, pn=1)
cmds.xform(srt_dummy, t=[0, 0, 0])
if mode == 'rot':
cmds.makeIdentity(sel, n=0, s=0, r=1, jointOrient=0, t=0, apply=True, pn=1)
cmds.xform(srt_dummy, ro=[0, 0, 0])
if mode == 'scale':
cmds.makeIdentity(sel, n=0, s=1, r=0, jointOrient=0, t=0, apply=True, pn=1)
cmds.xform(srt_dummy, s=[1, 1, 1])
if mode == 'joint':
if cmds.nodeType(sel) == 'joint':
cmds.makeIdentity(sel, n=0, s=0, r=0, jointOrient=1, t=0, apply=True, pn=1)
cmds.xform(srt_dummy, ro=[0, 0, 0])
if mode == 'trans' or mode =='all':
cmds.xform(sel+'.scalePivot', t=[0, 0, 0], os=True)
cmds.xform(sel+'.rotatePivot', t=[0, 0, 0], os=True)
except Exception as e:
print e.message
cmds.inViewMessage( amg=e.message, pos='midCenterTop', fade=True, ta=0.75, a=0.5)
set_attr_locked(sel, attr_lock_flag_list)
common.TemporaryReparent().main(sel, dummyParent=dummy, mode='parent')
common.TemporaryReparent().main(sel, dummyParent=srt_dummy, mode='parent')
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')#
common.TemporaryReparent().main(dummyParent=srt_dummy, mode='delete')#ダミー親削除
cmds.select(selections, r=True)
sisidebar_sub.get_matrix()
示例8: duplycateSymmetry
# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import scale [as 别名]
def duplycateSymmetry(object):
meshNode = cmds.listRelatives(object, s=True, pa=True, type='mesh', fullPath=True)
if meshNode is not None:
#エラー吐くことがあるのでノンデフォーマヒストリを削除
cmds.bakePartialHistory(object,ppt=True)
#ネームスペースから分割
nemeSplit = object.split('|')
newName = nemeSplit[-1]
#左右リネーム関数呼び出し
newName = renameLR(newName)
#複製して反転
duplicated = pm.duplicate(object, name=newName)
try:
parentNode = duplicated[0].firstParent()#Pymelの機能で親の階層を取得しておく。listRelativesと同じような。
parentNode = str(parentNode)#cmdsで使えるように文字列に変換
#左右リネーム関数呼び出し
newParent = renameLR(parentNode)
except:
parentNode = None
newParent = None
duplicated = str(duplicated[0])#cmdsで使えるように文字列に変換
#子供のオブジェクト取得関数呼び出し
children = pm.listRelatives(duplicated, ad=True, type='transform', f=True)
#子供のオブジェクトがある場合は重複を避けるため削除
if len(children) != 0:
cmds.delete(children)
#アトリビュートのロック解除
#全部のロック解除しないと親が変わったときのロカール値が変わらず、ズレることがある。
attr = ['.translate', '.rotate', '.scale']
axis = ['X', 'Y', 'Z']
for varA in range(0, 3):
for varB in range(0, 3):
cmds.setAttr(duplicated + attr[varA] + axis[varB], lock=False)
#ワールドスケール用ダミーロケータ作成
dummy = common.TemporaryReparent().main(mode='create')
cmds.parent(duplicated, dummy)
#X方向に-1スケーリングしてからスケールフリーズ
cmds.scale(-1, 1, 1, dummy, relative=True, pivot=(0,0,0))
#杏仁生成を防ぐためにダミーロケータのスケールをフリーズ、負の値が親に入ってると杏仁が生成されるような。
if cmds.nodeType(duplicated) == 'joint':
#ジョイントを正しい回転、位置に修正するため、スケールフリーズ前のグローバル値を取得しておく
pos = cmds.xform(duplicated, q=True, t=True, ws=True)
rot = cmds.xform(duplicated, q=True, ro=True, ws=True)
cmds.makeIdentity(dummy, apply=True, translate=False, rotate=False, scale=True, preserveNormals=True)
#元の親名と違い、かつ新しい親名のオブジェクトが存在する場合は付け替え
if parentNode is None:
cmds.parent(duplicated, w=True)
else:
if parentNode != newParent and cmds.ls(newParent):
cmds.parent(duplicated, newParent)
else:
cmds.parent(duplicated, parentNode)
#ダミーペアレントを削除
common.TemporaryReparent().main(dummyParent=dummy, mode='delete')
cmds.makeIdentity(duplicated, apply=True, translate=False, rotate=False, scale=True, preserveNormals=True)
if cmds.nodeType(duplicated) == 'joint':
cmds.xform(duplicated , t=pos, ro=rot, ws=True)
return duplicated