import pymel.core as pm
class PlayBackPrinter():
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
# print str("state : " +str(self.state))
def pbStop(self,*args):
pm.play(state=False)
self.state = False
# print str("state : " +str(self.state))
def pbPrintCurrentTime(self):
print pm.currentTime()
def pbListener(self):
t = pm.currentTime()
def main():
pbPrinter = PlayBackPrinter()
while pbPrinter.state==True:
pbPrinter.pbPrintCurrentTime()
main()
timeChange arg. The "off" button deletes the scriptJob. You'd want to put checks in so no more than one scriptJob gets made if the user keeps bonking 'on'. Should be about that simple. timeChange arg." as my skills in maya programming are very limited. I checked the a = pm.keyframe(query = True, timeChange = True) print aclass 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() 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()print ("The Frame!" + frame + " \n");
Totally works, and prints every frame during playback. I create and manage expressions from Python all the time: One button makes the expression node if it doesn't exist. The other button deletes it if it does. I'm still fuzzy on the how\why of all this, but I hope this helps ;)
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/kfpi8VrLpLw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f816eba4-7f6c-487b-ae20-2bc863453341%40googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/kfpi8VrLpLw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/4be104b4-a85e-4d7c-b28a-0cfd4911d4a9%40googlegroups.com.