algorithmic modeling for Rhino

So this is slightly off topic, but I think someone here might have a understanding of what is happening. I have also posted this on Rhino.Python, but I am still looking for the right answer. Technically this is a Rhino.Python problem and not a Grasshopper issue, but it could apply to both!

I was trying to take a simple example of moving a ball around and see how it could be animated through Rhino.Python. The code works great in wire frame with now memory issues at all. However, when I switch the view to Shaded or Rendered, things go south pretty quickly. The RAM usage of Rhino which was steady around 350mb (ish) now grows every frame after a minute or so, it is in the GB's and never drops even after the script has stopped.

What gives? Clearly this must be possible because Bongo does something similar when it does animations. Check out my code below and I would love to hear your thoughts.

import time
import rhinoscriptsyntax as rs
import Rhino
height = 100
width = 100
x = 0
y = 0
xspeed = .1
yspeed = .3
start_time = time.time()
end_time = 60
run_time = 0
sphere = rs.AddSphere((x,y,0)5)
while run_time < end_time:
    x = x + xspeed
    y = y + yspeed
    if x > width/2 or x < -width/2:
        xspeed = xspeed * -1
    if y > height/2 or y < -height/2:
        yspeed = yspeed * -1
    rs.MoveObject(sphere, (xspeed, yspeed, 0))
    run_time = time.time() - start_time

Views: 565

Replies to This Discussion

Bongo displays animations by just modding the display transform for objects. It doesn't actually transform objects until you render.

Could it just be undo recording in your case? Every time you move an object a copy of it is made, the original goes into undo-memory and the copy is moved. What if you limit your undo?


David Rutten

Poprad, Slovakia


So if I add the command rs.Command("_ClearUndo") at the end of the loop, that seems to solve the problem, however that is very sloppy in my opinion.

I have tried working with:

doc.UndoRecordingEnabled = False
print doc.UndoRecordingIsActive

But it always says recording is still active even when I set it to be false for the document.

We are on to something here, I would rather solve this with rhinoscipt / rhinocommon and not have to run a "command" to do it.







  • Add Photos
  • View All


  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service