Conduit autoscale arrow on mousemove event

Hi there,

I am working on an idea showing vectors via a conduit.
So far I am able to maket his work, I set up the conduit and I am able draw an arrow in the model space.

My question is: when I want this arrow to be the same screen size when I zoom, how would I do this?

My approach would be:
Translate the start and end point to the screen, on mouse move this would automatically be updated of course.
Rhino.Display.Rhinoviewport.WorldToClient()
Then I would draw a 2d line, still i would have no arrow.
Rhino.Display.DisplayPipeline.Draw2dLine

So is this approach the right one?
Or would I have to tackle this a bit differently?

Thanks,
T.

Hi @tobias.stoltmann,

you might test out DrawMarker or DrawArrow. Both allow to define size in pixels.

In case you want to control size of other drawing elements based on the screen scale, check out GetWorldToScreenScale

Edit: using a Line, you could also use DrawLineArrow and scale it yourself. Below Example just draws the mesh vertex normals while keeping the size of the arrows (defined in world units) at a constant screen size:

for v, n in zip(self.Mesh.Vertices, self.Mesh.Normals):
    rc, scale = e.Viewport.GetWorldToScreenScale(v)
    if rc:
        line = Rhino.Geometry.Line(v, n, 30/scale)
        e.Display.DrawLineArrow(line, Color.Black, 1, 5/scale)

_
c.

2 Likes

This is it, @clement!
Thanks a lot!