hi Eric and thx for your help.
I tried but really, I don' get it "passes the printer method to the
*timeChange* arg." as my skills in maya programming are very limited. I
checked the
pymel.core.animation.keyframe class, found timeChange attribute....but
then.. I tried to query it expecting I could detect when currentTime
changes, but got no return value..
a = pm.keyframe(query = True, timeChange = True)
print a
In my case I am not sure that scriptJob is appropriate as it's mel and I
want to use python class object and avoid any kind of call like
"python(blabla...)"
My previous print time sample code is maybe confusing so I updated my code
trying to make it clearer. Basically I defined a CustomLocator object. Each
time a frame is played after pressing Start button a custom locator is
drawn. Right now the locator is drawn when pressing the start button. But
it's not drawn each time a frame is played or updated and I still can' t
figure how to do it...
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()
Pseudo Code:
Press Start Button
>>Start Playback
>>>>While(currentTime changes):
DoTheJob()
Press Stop Button
>>Stop Playback
Le mardi 7 avril 2015 01:22:30 UTC+9, AK Eric a écrit :
>
> Off the cuff: Make a method that prints the current frame (like you've
> done). The "on" button of your ui calls to a *new *method that creates a
> scriptJob and passes the printer method to the *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.
>
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/3504d196-6b96-47b1-8696-26a309003693%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.