Animate in real time


I have a path consisting of some line segments and corresponding speeds in mm/s. I want to animate a dot moving along the path in real time:

The first segment is 100mm long, speed is 10mm/s so the animation should take 10s for the dot to travel to the first kink. [edit] I don’t need the image frames (.png) of the animation, just a preview of the movement with the real speed.

I suspect the best way is to do this with a script, but I am not sure how to start… Any tips?
Thanks! (4.3 KB)

Right-click the slider and choose the ‘Animate’ feature.
For different speeds in each segment, you will need to Explode the path curve and animate each segment separately.
Reparameterize the ‘C’ (curve) input of Evaluate Curve and use 0 to 1 sliders.

The real path consists of thousands of segments with different speeds, so splitting it up and using the “animate slider” function is unfortunately not practical. I don’t need the image frames (.png) of the animation either, it is more for previewing the movement inside gh in real time. Sorry if that was not clear.

What does “real time” mean?

The animation takes the same time as it would in the real world. e.g.

you just have to calculate how much time you need for each part of curve then sum all durations, sum all distances, make a curve with time on X and Y as the distance travelled. Then if you want a distance for the time traveled make a curve intersection. (10.9 KB)

I am just rusty I don’t know where I can get a duration live in Grasshopper !!!

1 Like

Now it must work, I added a trigger and a component that outputs seconds

seconds = (double) DateTime.Now.Hour * 3600 + (double) DateTime.Now.minute * 60 +(double) DateTime.Now.Second + (double) DateTime.Now.Millisecond / 1000;; (15.9 KB)

Edit : forgot the minutes !

1 Like

thank you for your help!

Timers are notoriously unreliable in Grasshopper. I used a Python hack from here:

And assumed 30 frames per second. (13.8 KB)

P.S. Changed FPS (frames per second) from 30 to 15 with timer interval at 33 milliseconds, which looks more accurate (real time) on my machine. Your mileage may vary… Also added CullPt (Cull Duplicates) to eliminate duplicate “frames” (points) where the segments meet. (14.7 KB)

NOTE: Stop the timer before quitting Rhino to avoid an error!

1 Like

I know, I know… But I realized that it was trivial to replace the timer with an animated slider, remapped to traverse the “keyframe” points I had generated (cyan group), and the resulting video would be more accurate than the erratic GH interval timer. This is at 24 FPS: (21.5 KB)