Draw point with Rhino.Display.DisplayPipeline.DrawDot() in RhinoPython?


Does somebody have an example on how to draw a Rhino.Geometry.Point3d() with Rhino.Display.DisplayPipeline.DrawDot() in RhinoPython?

Am I right in the assumption that this method just draws a dot with a shader?



Yes, it draws an ordinary annotation dot. Here is the simplest example i could do:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

class MyConduit(Rhino.Display.DisplayConduit):
    def __init__(self, points):
        self.Points = points
    def DrawForeground(self, e):
        for index, pt in enumerate(self.Points):
            e.Display.DrawDot(pt, str(index))

def RunScript():
    curve = Rhino.Geometry.Circle(50.0).ToNurbsCurve()
    points = [curve.PointAt(t) for t in curve.DivideByCount(10, True)]
    conduit = MyConduit(points)
    conduit.Enabled = True
    prompt = rs.GetString("Press Enter when done")
    conduit.Enabled = False

Some words of caution: Above conduit is disabled after pressing Enter. If you would not disable it, it continues to run (forever) after the script ends. If you build your own conduits, it is a good practice to put the conduit instance into scriptcontext.sticky so you can later get hold of it, eg. to disable it.



Wow, thank you very much for the example! It’s much appreciated!! :slight_smile:

Noted. I believe I’ve encountered this with the latest version of the ghgl Grasshopper add-on, where drawn stuff often times remains visible after you’ve deleted the relevant components from the Grasshopper canvas, until Rhino is relaunched.

Am I right in the assumption that the MyConduit class is essential since it inherits from Rhino.Display.DisplayConduit? Does it override the DrawForeground() method of the mother class? Or how does this work? What exactly is the input parameter e?

Thanks again, Clement.

I would say yes. Without creating an instance from it, there would be no conduit.

Yes, and also DrawOverlay, PostDrawObjects, PreDrawObject, PreDrawObjects and PreDrawTransparentObjects.

I am not the best explaining this in detail. I would recommend this:


The e is the DrawEventArgs for this drawing event. See this for more info.


1 Like