How do I run script during a simulation?

Post Reply
hardin@cdgengineers.com
Posts: 4
Joined: Mon Dec 12, 2011 5:32 pm
Location: St. Louis, Missouri

How do I run script during a simulation?

Post by hardin@cdgengineers.com » Tue Dec 20, 2011 3:51 pm

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.
Lyle

User avatar
Alex
Site Admin
Posts: 143
Joined: Mon Jun 14, 2010 9:35 am

Re: How do I run script during a simulation?

Post by Alex » Tue Dec 20, 2011 4:08 pm

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.
Alex Ribao
RealFlow Team
Next Limit Technologies

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: How do I run script during a simulation?

Post by tsn » Wed Dec 21, 2011 9:22 am

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).
Thomas Schlick | Next Limit Technologies

hardin@cdgengineers.com
Posts: 4
Joined: Mon Dec 12, 2011 5:32 pm
Location: St. Louis, Missouri

Re: How do I run script during a simulation?

Post by hardin@cdgengineers.com » Wed Dec 21, 2011 3:40 pm

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?
Lyle

User avatar
tsn
Posts: 283
Joined: Fri Jun 11, 2010 7:22 am

Re: How do I run script during a simulation?

Post by tsn » Wed Dec 21, 2011 4:15 pm

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.
Thomas Schlick | Next Limit Technologies

Post Reply