Display Pipeline draw objects

Hi,

I’m working on a simple python script that dynamically creates and animates geometry. I got it working in 2D easily, but having issues rendering 3D geometry in the display pipeline. I can render the temporary geometry with curves easily, but not with spheres. I wonder if I’m doing something wrong.

Here’s the working draw code:

def draw(dp, frame, geom):
    # dp is display pipeline see rhino common docs
    for circ in circles:
        pt = rs.CreatePoint(circ.pos.X, circ.pos.Y, circ.pos.Z)
        cir = Rhino.Geometry.Circle(pt, circ.radius)
        dp.DrawCircle(cir, rs.CreateColor(circ.color))

Here’s the non-working code:

def draw(dp, frame, geom):
    # dp is display pipeline see rhino common docs
    for circ in circles:
        pt = rs.CreatePoint(circ.pos.X, circ.pos.Y, circ.pos.Z)
        sph = Rhino.Geometry.Sphere(pt, circ.radius)
        dp.DrawSphere(sph, circ.color)

Any help would be appreciated!

Moved to Scripting category

Hi @Galo_Canizares,

DrawSphere should just draw a wireframe sphere. Is this not what you’re seeing?

– Dale

Hi Dale,

I did get the wireframe spheres to work. It looks like the issue was the way the color was formatted. I guess I’m not understanding how the DrawSphere, DrawBox methods etc. work with color. I could only get it to work by calling something like System.Drawing.Color.Red. Is there a way to use RGBA values?

G

You can use System.Drawing.Color.FromRGBA.

1 Like

Thanks! This is exactly what I was looking for.