TheSwamp
Code Red => .NET => Topic started by: itcad on December 18, 2007, 08:34:14 PM
-
How to use "Editor.PointToScreen " ?
-
What have you tried ?
-
What have you tried ?
I want to put cursor to a point3d.
-
POst your code you have tried and we can see whats wrong
-
POst your code you have tried and we can see whats wrong
My code:
Point3d pt = new Point3d(100, 200, 0);
Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
int viewPortNumber = Convert.ToInt32(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("cvport").ToString());
Cursor.Position = ed.PointToScreen(pt, viewPortNumber);
Run my code,Position of cursor is different from the pt(100, 200, 0).
why?
-
What have you tried ?
I want to put cursor to a point3d.
Is this what you are looking for?
[CommandMethod("Hola", CommandFlags.Modal)]
public static void MyCommanderIsMyWife()
{
Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
int viewPortNumber = Convert.ToInt32(AcAp.Application.GetSystemVariable("CVPORT"));
Point3d ToThePoint = ed.PointToWorld(System.Windows.Forms.Cursor.Position, viewPortNumber);
ed.WriteMessage(ToThePoint.ToString());
}
[CommandMethod("Mola", CommandFlags.Modal)]
public static void MyCommanderIsMyDaughter()
{
Editor ed = AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
int viewPortNumber = Convert.ToInt32(AcAp.Application.GetSystemVariable("CVPORT"));
System.Drawing.Point ToThePoint = ed.PointToScreen(new Point3d(0, 0, 0), viewPortNumber);
ed.WriteMessage(ToThePoint.ToString());
}
-
I seem to be getting almost the correct result with the following. Not exactly right, but close. It also attempts to put the cursor on the point even if the point is not visible on-screen, which may result in a cursor that is way off the visible screen.
Point3d pt = new Point3d(100, 200, 0);
Autodesk.AutoCAD.ApplicationServices.Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
int viewPortNumber = Convert.ToInt32(Autodesk.AutoCAD.ApplicationServices.Application.GetSystemVariable("cvport").ToString());
System.Drawing.Point ptOffset = ed.PointToScreen(pt, viewPortNumber);
System.Drawing.Point windowLocation = doc.Window.Location;
Cursor.Position = new System.Drawing.Point(windowLocation.X + ptOffset.X, windowLocation.Y + ptOffset.Y);