GH Python : simple gravity problem

Dear All,

I have been following a tutorial from Jake Hebbert’s channel on Youtube and trying to make a simulation of a bouncing ball with friction and gravity constraint but the animation (simulation) was moving very slow and I have a syntax error to define “normal”. I hope anyone can help me. Thank yousimple gravity and|attachment (15.3 KB)

Hey @kukarteknis,

There seems to be something wrong with your file upload!

i will upload it again.

simple gravity and (15.3 KB)

@JakeHebbert’s approach, although superb for learning GHPython, isn’t very optimised and kind of outdated.

The main issue is that he saves all the necessary information for the simulation (i.e. posList, massList) for each moment in time into an ever growing nested list that he then loops over outside of the GHPython component to animate stuff.
In your example, you store 1000 iterations x 13 movers x 2 pieces of information per mover, equals 26000 list items, and that doesn’t even include the 13 mover instances that are stored separately.
It would be a better move to animate the GHPython component itself, only store the movers to the sticky dictionary or globals(), and output the necessary information at each iteration only.

Also RhinoCommon would be faster than using the rhinoscriptsyntax, because it cuts out the middleman.

Can you be a little more specific about this? What does the error message say exactly?
The script runs fine for me. Maybe the error is in your

1 Like

Here’s a rough translation of your script into rhinocommon!

It’s not perfect, but it runs quite good. I’ve implemented most of the stuff I wrote about above. Friction is also applied now when the balls hit the ground plane! (11.4 KB)


Thank you for your answer. I think I will do more research on RhinoCommon. By the way, this is the (I copy this file from Jake Hebbert tutorial) (3.8 KB) ).

1 Like