Page 1 of 1
How do I run script during a simulation?
Posted: Tue Dec 20, 2011 3:51 pm
by hardin@cdgengineers.com
How does one run a script with each frame of a simulation?
I can load a script and run it easy enough before a simulation, but I can't determine from the Realflow manual how to run a script DURING a simulation. To be specific, I have a small script I want to run at each frame of the simulation. Or, now that I think about it, during just the first 100 (or so) frames. This may be a 1000 frame simulation.
Re: How do I run script during a simulation?
Posted: Tue Dec 20, 2011 4:08 pm
by Alex
Hi,
you should have a look at the Simulation Events panel (and its section in RealFlow manual).
There you will have access to the different simulation events when you can run a script.
You can use the scene.getCurrentFrame() function to check what you want to do on your script depending on the frame number.
Re: How do I run script during a simulation?
Posted: Wed Dec 21, 2011 9:22 am
by tsn
hardin@cdgengineers.com wrote:How does one run a script with each frame of a simulation?
I can load a script and run it easy enough before a simulation, but I can't determine from the Realflow manual how to run a script DURING a simulation.
Please have a look at the manual, page 299-300, Simulation Events. We recommend to use the events inside the "Simulation Events" tree. Maybe you got a little confused because of the "Master" tab. This is actually only for backward compatibility purposes and shouldn't be used anymore (though some people still do so).
Re: How do I run script during a simulation?
Posted: Wed Dec 21, 2011 3:40 pm
by hardin@cdgengineers.com
Thanks for the replies.
I have it working now, running my script with each frame inside Events and for a certain amount of frames.
But....
When the simulation is done, the animation.sd file exported from Realflow doesn't contain the whole simulation.
When I import it into MAX, I only get a static object or two (like a Realflow plane or vase object) and no animated objects (none of my flying cubes that I've worked so hard to make).
Also, in Realflow, when I move the timeline slider back and forth after a simulation, nothing happens.
So,
If I just run my script outside of the Events then run the simulation, everything is recorded in the animation.sd file and the time slider recreates the simulation as I slide it back and forth.
When my script is run inside the Events during a simulation, the animation.sd file is essentially empty and the time slider does nothing.
Is this a bug or am I missing something in my code?
Re: How do I run script during a simulation?
Posted: Wed Dec 21, 2011 4:15 pm
by tsn
It's neither a bug nor did you miss anything: in RF it's possible to add RBD objects dynamically (= during a simulation), but the position and rotation data aren't written to the corresponding SD/BDC files. Everything you get is just a "stack" of overlapping objects at frame 0, but without any motion. If you want to keep the motion of the objects you have to bake their animation data into curves with Python. This has to be done for each object individually. This process will only conserve the animation paths, but not the point in time when the bodies enter the scene. This is currently not possible at all and so you'll again end up with all objects overlapping.