0
更新:) 我有一個用戶界面,帶有2個控制播放,「播放」和「停止」的按鈕。 我定義了一個CustomLocator對象。當按下開始按鈕後播放正在運行時,我希望每次播放幀時創建並繪製一個customLocator 。現在當按下開始按鈕時繪製定位器。但它每幀播放時間不抽,我可以」 T數字該怎麼辦呢?感謝您的幫助Maya Python Playback每次播放幀時創建對象
class PlayBackDoSomething():
def __init__(self):
self.drawUI()
self.state = False
def drawUI(self):
if pm.window("UI_MainWindow", exists = True):
pm.deleteUI("UI_MainWindow")
pm.window("UI_MainWindow", title = "test playback...", w = 150, h = 150, mnb = False, mxb = False, sizeable = True)
pm.columnLayout("UI_MainLayout", w = 150, h =300)
pm.button("UI_pbStartButton", label = "Start", w = 150, command=self.pbStart)
pm.button("UI_pbStopButton", label = "Stop", w = 150, command=self.pbStop)
pm.showWindow("UI_MainWindow")
def pbStart(self,*args):
pm.play(state=True)
self.state = True
self.doTheJob()
def pbStop(self,*args):
pm.play(state=False)
self.state = False
self.stopTheJob()
def doTheJob(self):
#this is basically part of code that i want to execute each time a frame is updated after pressing Play button
print ("start of job")
a = pm.keyframe(query = True, timeChange = True)
print a
t = pm.currentTime()
cl = CustomLocator(t, 0,0)
cl.draw()
def stopTheJob(self):
print ("end of job")
class CustomLocator():
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
def draw(self):
pm.spaceLocator(p=(self.x, self.y, self.z))
pm.spaceLocator(p=(self.x, self.y, self.z-5))
pm.spaceLocator(p=(self.x, self.y, self.z+5))
def main():
pb = PlayBackDoSomething()
main()
感謝您的幫助,因爲我的代碼對於我真正期望做的事情有點困惑,我只是更新了我的帖子 – user2383294 2015-04-07 03:01:51
表達式編輯器與python對象非常慢,所以我寧願不考慮該選項。強制更新使用cmds.currentTime()的時間並不壞..我可以啓動一個循環並用我的開始按鈕迭代cmds.currentTime(i + = 1),但我不知道如何使用停止按鈕來分解它。 .. – user2383294 2015-04-07 05:32:15
中斷這樣一個過程的唯一方法是使用主進度條,將其設置爲可互換,並讓用戶從那裏停止。手動創建的UI元素在腳本執行期間不會處於活動狀態。 – theodox 2015-04-07 18:09:01