PDA

View Full Version : Get current time in Layout through Master Script



ernpchan
10-15-2014, 03:34 PM
I have a Master script where I'm getting the current time of the time slider in Layout. I get the correct time after hitting 'OK' in my script but when I change my time slider and hit 'OK' again it only returns the first found time. Not the new time.

What is my code missing? Below is a snippet of how I have things:



def event(self,ma):
if ma.eventCode == lwsdk.LWEVNT_TIME:
print lwII.curTime
pass
return 0.0

def ok(self,control,data):
myTime = lwII.curTime
print myTime

ernpchan
10-15-2014, 03:51 PM
Changing the code to the below seems to have worked:



def event(self,ma):
if ma.eventCode == lwsdk.LWEVNT_TIME:
print lwII.curTime
pass
return 0.0

def ok(self,control,data):
myTime = lwsdk.LWInterfaceInfo().curTime
print myTime

Sensei
10-15-2014, 04:16 PM
"curTime
The current animation time selected in the Layout interface. "

I don't think so, you're really interested what user slider is set to... That's "good" for LayoutGeneric, once run, then quit.

Try using Layout TimeInfo.
LWSDK/html/globals/timeinfo.html

Remember that master should be also run in F10 image sequence rendering, and LWSN.

Sensei
10-15-2014, 04:23 PM
When we're doing this in C/C++ time is in data parameter send to LWEVNT_TIME,
this value has to be copied to per-instance storage variable declared by programmer.
Then that storage can be read, instead of calling global.
You can't take global which ends with "info" once at beginning, and then all the time reusing its fields in the rest of plugin code. These data are long time devaluated. *)
Each time you need it, you have to call it just before using.
Especially in such long running entity as master plugin class.

*) especially true for Modeler's EDPointInfo/EDEdgeInfo/EDPolygonInfo..