import maya.cmds as cm
import random as random
myList = cm.ls (sl = True)
class MovingObjects:
def up(*arg):
for objects in myList:
cm.move(0,0.5,0 ,r = True)
def down(*arg):
for objects in myList:
cm.move(0,-0.5,0 ,r = True)
class microMove(MovingObjects):
def microUp(*arg):
cm.move(0,0.1,0 , r = True)
def microDown(*arg):
cm.move(0,-0.1,0 , r = True)
class declare:
def transformDeclare(*arg):
for objects in myList:
print('%s'%objects)
print(cm.getAttr('%s.translateX'%objects))
print(cm.getAttr('%s.translateY'%objects))
print(cm.getAttr('%s.translateZ'%objects))
class randomTransform:
def Randomize(*arg):
for objects in myList:
cm.xform('%s'%objects , ws=True,t=[random.uniform(-10,10),random.uniform(-10,10),random.uniform(-10,10)])
M = MovingObjects()
D = declare()
mM = microMove()
RT = randomTransform()
cm.headsUpMessage('First: "please select objects"', verticalOffset=300)
cm.window(t = 'X-transform' , h = 150 , w = 500 , s = False)
cm.columnLayout()
cm.button(l = 'Up' , c = M.up , w = 300 , h = 50 , bgc = (0,0.7,0.7) )
cm.button(l = 'micro-Up' , c = mM.microUp , w = 300 , bgc = (0,1,1))
cm.button(l = 'micro-Down' , c = mM.microDown , w = 300 , bgc = (0,1,1))
cm.button(l = 'Down' , c = M.down , w = 300 , h = 50 , bgc = (0,0.7,0.7) )
cm.button(l = 'Randomizing-objects-transform' , h = 50 , w = 300 , c = RT.Randomize , bgc = (0.8,0.8,0))
cm.button(l = 'Transformation-info' , c = D.transformDeclare , w = 300 , h = 50 )
cm.text( label='Script by : Amin-khormaei', align='center' )
cm.showWindow()
cm.error('Hey dude.. this is it')
嘿,伙计们,我有两个问题 4 是吗?
1:最后一行 cm.error('X') 给我一个运行时错误
2:类声明仅适用于我第一次运行它,当我想获取刷新转换信息时,我应该再次运行脚本
请帮助duuuudes。
最好的祝福。