Author Topic: Need Help on Screen Point location  (Read 2858 times)

0 Members and 1 Guest are viewing this topic.

Andrea

  • Water Moccasin
  • Posts: 2372
Need Help on Screen Point location
« on: March 16, 2011, 02:21:34 PM »
Hi all...

i'm trying to find the equivalent position in screen pixel resolution (X and Y) when using GRREAD or clicking a simple point.
any suggestion ?


thanks.
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Need Help on Screen Point location
« Reply #2 on: March 16, 2011, 03:08:31 PM »
Thanks Lee..

but it is not exactly what I need...
In fact,..Just to  know a way to convert (grread) cursor position to Pixel Screen Resolution.
Keep smile...


BlackBox

  • King Gator
  • Posts: 3770
Re: Need Help on Screen Point location
« Reply #4 on: March 16, 2011, 03:24:21 PM »
"How we think determines what we do, and what we do determines what we get."

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Need Help on Screen Point location
« Reply #5 on: March 16, 2011, 03:33:17 PM »
Using

Code: [Select]
(/ (getvar 'VIEWSIZE) (cadr (getvar 'SCREENSIZE)))
will indeed provide the 'length' of a pixel in AutoCAD Drawing units, but this will still only be defined from the origin of the drawing...

Hence, conversion to Screen Pixels relative to the drawing origin would be:

Code: [Select]
(defun c:test ( / p )

  (if (setq p (getpoint "\nPoint: "))
    (
      (lambda ( s ) (mapcar 'fix (mapcar '* p (list s s))))
      (/ (cadr (getvar 'SCREENSIZE)) (getvar 'VIEWSIZE))
    )
  )
)
« Last Edit: March 16, 2011, 03:41:53 PM by Lee Mac »

LE3

  • Guest
Re: Need Help on Screen Point location
« Reply #6 on: March 16, 2011, 04:01:29 PM »
if you could export to autolisp any of these functions from the arx sdk or pinvoke them in case they are not available from .net (that's what i use now):
acedCoordFromPixelToWorld();
acedCoordFromWorldToPixel();

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Need Help on Screen Point location
« Reply #7 on: March 16, 2011, 05:54:38 PM »
Well...

thank you guys....
After testing all founded code....it seem that's it is not working for me or it is not what i'm trying to have..
In fact,...this seem to be more complicated than i've thought.

The pixel result of AutoCAD cursor coordinate depend for many thing.
AutoCAD application windows size, location, DWG window docked or not, screen resolution per dual screen or not, ribbon window status,
......and so on....

All I can do right now, is to capture the autoCAD windows size and location..
But I can't found a way how to manage the AutoCAD windows position vs the screen resolution...to have ....the cursor Desktop position.

Thank you again for all your Help.
If someone find a way to manage that, i'll take it.

Peace.  :kewl:
Keep smile...

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Need Help on Screen Point location
« Reply #8 on: March 16, 2011, 06:00:26 PM »
After testing all founded code....it seem that's it is not working for me or it is not what i'm trying to have..

As I stated: This method implemented in the code I posted will only ever return the Pixel Dimension relative the Active Drawing Origin.

To get the absolute position in pixels using this method you would have to determine the position of the Drawing Origin relative to the bottom-left corner of the AutoCAD Window (i.e. taking into account the positions of all the surrounding toolbars and whether or not the Drawing Window is docked in the Application Window), and furthermore determine the position of the bottom-left corner of the AutoCAD Window relative to the bottom-left corner of the Screen (this would depend upon the position and state of the AutoCAD Window); then, with these vectors, transform the return from my code to obtain the correct position.

With all these factors to consider I would most likely attempt a different method entirely.
« Last Edit: March 16, 2011, 06:18:42 PM by Lee Mac »