Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5896

Animate Rhino Viewport with Rhino Python?

$
0
0

@p1r4t3b0y wrote:

Hi everybody,

Is it possible to animate the Rhino viewport with Python in order to run, for example a simulation that you can follow in real time, instead of seeing just the outcome. I’m currently looking for a Rhino Python solution without grasshopper!

A simple example would be a moving point that is - each frame or iteration - randomly displaced, and its movement can be seen live in the Rhino viewport.

I tried this, but it didn’t really work:

import Rhino.Geometry as rg
import rhinoscriptsyntax as rs
import random
import time

run_time = 10

pt = rg.Point3d(0.0, 0.0, 0.0)

for t in range(run_time):
    vec = rg.Vector3d(random.random(), random.random(), 0.0)
    pt += vec
    pt_id = rs.AddPoint(pt)
    time.sleep(.25)
    if t < run_time - 1:
        rs.DeleteObject(pt_id)

Getting the timing right is nearly impossible and creating, then deleting objects each frame is probably not very clever either!

Any suggestions?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5896

Trending Articles