Screen to world Offset?

Hi I need to draw a point on the Cplane under the mouse… but the routine I grabbed from the samples has a big offset?

        class CustomConduit : DisplayConduit
        protected override void PostDrawObjects(DrawEventArgs e)
            RhinoView view = RhinoDoc.ActiveDoc.Views.ActiveView;
            var P = Cursor.Position;
            Transform xform = view.ActiveViewport.GetTransform(CoordinateSystem.Screen, CoordinateSystem.Camera);
            Point3d world_point = new Point3d(P.X, P.Y, 0.0);
            e.Display.DrawPoint(world_point, Color.DarkRed);

and this is what I am getting? How can I get a point directly under my mouse

I am not using any kind of GET, I need this outside of any of those routines.

Hi @ChristopherBotha,


Transform xform = view.ActiveViewport.GetTransform(

should be this:
Transform xform = view.ActiveViewport.GetTransform( CoordinateSystem.Screen, CoordinateSystem.World // << );

– Dale

Hi Dale.

Exact same offset. Except only in one window.

RhinoView view = RhinoDoc.ActiveDoc.Views.ActiveView;
RhinoViewport viewport = e.Viewport;

The proper viewport is passed to the conduit for each viewport being drawn.

You also need to make the change that Dale suggested.

1 Like

Thanks. Will give that a whirl!

nope, same offset using this code.

Ah, Cursor.Position is in screen coordinates, not to local client coordinates of your window.

P = view.ParentView.ScreenToClient§;

to convert the screen point

1 Like

That fixed it up, thank you!

Ha! Was going for an implementation of Zbrush LazyMouse for freehand sketching… remember to turn off overrides before exiting a command :wink:

(lazyMouse working great though, thanks for the help.