Add Text at mouse cursor position

I’m trying to add text exactly at the position of the mouse cursor.
But I’m having trouble getting the position where the mouse is on the Rhino screen
Below is my code.

        Rhino.Display.RhinoView view = doc.Views.ActiveView;
        Transform xform = view.ActiveViewport.GetTransform(
        Point3d pt = new Point3d(?????.X, ?????.Y, 0.0);

        Plane position = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();
        position.Origin = pt;
        Guid te = doc.Objects.AddText("test", position, 7, "Arial", false, false);

        return Result.Success;

Would someone have a solution for this?

If you are not going to use a GetPoint object to obtain a 3d point location, then you can Pinvoke the GetCursorPos Win32 function to get the current mouse cursor position. This is a 2d point, so you will need to transform it to a 3d point location using a screen-to-world coordinate transformation.

– Dale

1 Like

Hi dale
Is there no way to get X and Y of rhino screnn through rhinocommon?


No, not unless you are using a GetPoint object…

Ok, dale