Drawing 2D lines or Rectangles

I am trying to create a new plugin which I want to be able to draw rectangles on the active viewport. It looks like it could be possible to do it by calculating the positions of lines and drawing them. However if possible I would like to see if their is an easier way of doing it.

I noticed in the rhinocommon gitlab project that their is a commented out definition for draw2dline and Draw2dRectangle, which seem like they would be exactly what I am looking for. So does anyone have any suggestions, or idea if/when those 2 functions would be usable?

edit: I forgot to say this, I am using C# and am trying to do this in a display conduit (which seemed the logical place)

Do you want to draw these lines in “screen space” (window coordinates)?

Yes, I have found a way that would possible to do it by drawing to a bitmap then drawing that bitmap onto the scene which will work if need be, if their is an easier/better way of doing it then that would be awesome.

I’ll try to make a convenient function for this on the DisplayPileline class in the future, but for now you should be able to get the transform of screen to world from the viewport. Something like the following.

var transform = e.Viewport.GetTransform(CoordinateSystem.Screen, CoordinateSystem.World);
// convert screen points to world.
e.Display.DrawLine(screen_point1, screen_point2, Color.Red);

Awesome, that looks like it will work exactly how we wanted it and a convenience function would be amazing.