Get mouse position in active viewport + cplane coords

How to get the 2d - relative to the viewport windows and 3d coordinates of the active cplane?

Reason why would be custom object creation (not get, set style, but rather a scatter painter or similar)
the 2d would be to interact with Hud-style displayconduit elements.
(rhino5, c#, or similar)

AFAIK there is no example in C# but you would need the Viewport.GetPickTransform() if I'm not mistaken. (see below)

To transform a 2-D screen point to a 3-D world xy-plane point, you can do something like this:

Rhino.Display.RhinoView view = doc.Views.ActiveView;
Rhino.Geometry.Transform xform = view.ActiveViewport.GetTransform(
Rhino.Geometry.Point3d world_point = new Rhino.Geometry.Point3d(
1 Like

i don’t really understand what you mean dale, but i think i figured it out more or less:

RhinoView view = doc.Views.ActiveView;
RhinoViewport vp = view.ActiveViewport;

System.Drawing.Point p = vp.ScreenToClient(Cursor.Position);
Line l = vp.ClientToWorld(p); // this gives a point exactly over the cursor

I didn’t figure out yet what defines the depth of the point, but its a good start - and i think the code from dale could be the next step to bring the point to a plane

edit: just realized that my initial post was a bit vague on what i wanted to achieve: to get the coordinates that are shown in the lower left corner of rhino

This is exactly what my sample code shows how to do…