これは私のコードです:
def animate(*arg):
cvList = []
myList = cm.ls(sl =True)
randList1 = [rand.uniform(-10,10)for items in range(10)]
for i in myList:
cvList = cm.ls(i+".cv[:]" , flatten = True)
for j in cvList:
cm.setKeyframe(j , ".cv[0].xValue" , t = cm.intField(time1 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[0].xValue" , t = cm.intField(time2 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[0].yValue" , t = cm.intField(time1 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[0].yValue" , t = cm.intField(time2 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[0].zValue" , t = cm.intField(time1 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[0].zValue" , t = cm.intField(time2 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[1].xValue" , t = cm.intField(time1 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[1].xValue" , t = cm.intField(time2 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[1].yValue" , t = cm.intField(time1 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[1].yValue" , t = cm.intField(time2 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[1].zValue" , t = cm.intField(time1 , query = True , value = True) , v = rand.choice(randList1) )
cm.setKeyframe(j , ".cv[1].zValue" , t = cm.intField(time2 , query = True , value = True) , v = rand.choice(randList1) )
animWindow = cm.window(t = 'Animation controls' , w = 150 , menuBar = True , bgc = [.2,.2,.2])
cm.menu(l = 'About' , tearOff = False )
cm.menuItem( l = 'Version 1.0.0')
cm.columnLayout()
cm.text(l = 'Time 1' , w = 150)
time1 = cm.intField()
cm.text(l = 'Time 2' , w = 150)
time = cm.intField()
cm.button(l = 'Set key' , c = animate , w = 150, bgc = [.3,.3,.3])
cm.showWindow(animWindow)
これは私が得たエラーです:
# NameError: global name 'time1' is not defined #
その後、マヤはtime2が同じだと教えてくれます
私はこれをこれで使用しましたが、うまくいきました:
def tinyRandomize(*arg):
myList = cm.ls (sl = True)
randoms = [rand.uniform(cm.floatField(Ceil, q = True , v = True),0.5)for i in range(30)]
for objects in myList:
cm.xform('%s.cv[0]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[1]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[2]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[3]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[4]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[5]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[6]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[7]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[8]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[9]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[10]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[11]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[12]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[13]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[14]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[15]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[16]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[17]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[18]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[19]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
cm.xform('%s.cv[20]'%objects , r = True , t = [(rand.choice(randoms)),(rand.choice(randoms)),(rand.choice(randoms))])
この定義にGUIを追加しましたが、完全に機能しています
私を助けてください。
よろしくお願いします