Bug with DisplayConduit


(Matthieu Arnold) #1

Hi, I think there is a bug in rhinocommon’s DisplayConduit, more precisely in Protected Overrides Sub PreDrawObject(e As DrawObjectEventArgs).

When I use this:

    Dim pt = New Rhino.Geometry.Point3d(location.X, location.Y - 10, location.Z)
    e.Display.Draw2dText("TextContent", Color.Black, pt, True, True, "Arial")

the “dot” is displayed with no text but still sized according to the text. When the associated object is selected the text appear, and disappear when unselected.

When I use this:

Dim MyTextDot As New Rhino.Geometry.TextDot("TextContent", New Rhino.Geometry.Point3d(location.X, location.Y + 10, location.Z))
            MyTextDot.FontHeight = FontHeight
            e.Display.DrawDot(MyTextDot, DisplayColor, Color.Black, BorderColor)

the text never shows.

I tried using the same code in other subs such as Protected Overrides Sub PostDrawObjects(e As DrawEventArgs) and it works.

(Matthieu Arnold) #2

(Using rhino 6.5)

(Dale Fugier) #3

Hi @Matthieu_from_NAVINN,

Is there a reason you don’t just draw in PostDrawObjects? This is where you should probably be drawing your text…

– Dale

(Matthieu Arnold) #4

Hi @dale,
I can’t use PostDrawObjects because I need to call e.RhinoObject from DrawObjectEventArgs and it is only available for PreDrawObject.

I need to draw specific texts around rhinoobjects’ location based on some objects locations and attributes.

(Dale Fugier) #5

Hi @Matthieu_from_NAVINN,

During PreDrawObject, you should accumulate and cache what you need to use in PostDrawObjects.

– Dale

(Matthieu Arnold) #6

Thanks a lot @dale, this is a nice solution for me! Too bad it doesn’t work directly in PreDrawObject

Even if caching the data works, it’s not perfect: the created textdot is only drawn after I move the view (or click or zoom). I thought about refreshing the view but it would create an infinite loop.
Still for now I should be fine with this workaround.