Author Topic: How to use "Editor.PointToScreen " ?  (Read 5239 times)

0 Members and 1 Guest are viewing this topic.

itcad

  • Guest
How to use "Editor.PointToScreen " ?
« on: December 18, 2007, 08:34:14 PM »
How to use "Editor.PointToScreen " ?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: How to use "Editor.PointToScreen " ?
« Reply #1 on: December 18, 2007, 10:31:54 PM »

What have you tried ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

itcad

  • Guest
Re: How to use "Editor.PointToScreen " ?
« Reply #2 on: December 19, 2007, 02:22:44 AM »

What have you tried ?


I want to  put cursor to a point3d.

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: How to use "Editor.PointToScreen " ?
« Reply #3 on: December 20, 2007, 09:49:14 AM »
POst your code you have tried and we can see whats wrong
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

itcad

  • Guest
Re: How to use "Editor.PointToScreen " ?
« Reply #4 on: December 20, 2007, 07:55:34 PM »
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?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8744
  • AKA Daniel
Re: How to use "Editor.PointToScreen " ?
« Reply #5 on: December 21, 2007, 02:04:22 AM »

What have you tried ?


I want to  put cursor to a point3d.

Is this what you are looking for?

Code: [Select]
   [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());
    }
« Last Edit: December 21, 2007, 02:16:39 AM by Daniel »

sinc

  • Guest
Re: How to use "Editor.PointToScreen " ?
« Reply #6 on: December 21, 2007, 08:59:59 PM »
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.

Code: [Select]
            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);