Author Topic: How you do get the Current Screen's Coordinate ??  (Read 7714 times)

0 Members and 1 Guest are viewing this topic.

kraz

  • Guest
How you do get the Current Screen's Coordinate ??
« on: October 27, 2008, 12:32:14 AM »
what are you called cad's screen? window?
anyway, i want to know current cad screen's 4 coordinate..or 2.
but the way that with viewctr, viewsize ....as following..is not good way for me.
##############################################################
(example)
(defun cur_screen_coo ( / scrsize viewsize viewctr width lx ly lz rx ry rz)
 (setq scrsize (getvar "screensize")
       viewsize (getvar "viewsize")
       viewctr (getvar "viewctr")
 )
 (setq width (* (/ (nth 0 scrsize) (nth 1 scrsize)) viewsize))
 (setq lx (- (nth 0 viewctr) (/ width 2))
       ly (- (nth 1 viewctr) (/ width 2))
       lz 0
       rx (+ (nth 0 viewctr) (/ width 2))
       ry (+ (nth 1 viewctr) (/ width 2))
       rz 0
 )
 (list (list lx ly lz) (list rx ry rz))
)
##############################################################

there is many user's cad app windows...
and it is not return exactly.
« Last Edit: October 27, 2008, 12:37:27 AM by kraz »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How you do get the Current Screen's Coordinate ??
« Reply #1 on: October 27, 2008, 01:07:58 AM »
Perhaps --

Code: [Select]
(defun VPCords ( )
    (   (lambda (offset)
            (   (lambda (viewctr)
                    (list
                        (mapcar '- viewctr offset)
                        (mapcar '+ viewctr offset)
                    )
                )
                (getvar "viewctr")
            )
        )
        (   (lambda (halfHeight aspectRatio)
                (list
                    (* halfHeight aspectRatio)
                    halfHeight
                )
            )
            (* 0.5 (getvar "viewsize"))
            (apply '/ (getvar "screensize"))
        )
    )
)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

kraz

  • Guest
Re: How you do get the Current Screen's Coordinate ??
« Reply #2 on: October 27, 2008, 11:48:28 PM »
wow...it's very nice....exactly return the current screen coords...

thanks...

kraz

  • Guest
Re: How you do get the Current Screen's Coordinate ??
« Reply #3 on: October 27, 2008, 11:56:10 PM »
the MP's lisp is very nice....

but i can not understand .... why it does...

Could you please explain the source with commentary ?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8785
  • AKA Daniel
Re: How you do get the Current Screen's Coordinate ??
« Reply #4 on: October 28, 2008, 01:11:56 PM »
 8-)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How you do get the Current Screen's Coordinate ??
« Reply #5 on: October 28, 2008, 03:20:53 PM »


Let me know what part(s) you don't understand and I'll (try to) advise.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Matt__W

  • Seagull
  • Posts: 12955
  • I like my water diluted.
Re: How you do get the Current Screen's Coordinate ??
« Reply #6 on: October 28, 2008, 04:12:50 PM »
Let me know what part(s) you don't understand and I'll (try to) advise.

What editor are you using?   :?
Autodesk Expert Elite
Revit Subject Matter Expert (SME)
Owner/FAA sUAS Pilot @ http://skyviz.io

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How you do get the Current Screen's Coordinate ??
« Reply #7 on: October 28, 2008, 04:35:22 PM »
What editor are you using?  :?

For ascii matter ultra edit, for pixel dust paint shop pro.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

gskelly

  • Newt
  • Posts: 185
Re: How you do get the Current Screen's Coordinate ??
« Reply #8 on: October 28, 2008, 07:57:53 PM »
Just have to say I love reading the lists on this site... Just wish this sort of stuff would "come to me" when I sit down to do solve something!!!
Bricscad v12

kraz

  • Guest
Re: How you do get the Current Screen's Coordinate ??
« Reply #9 on: October 28, 2008, 09:37:54 PM »
I wonder why it return the correct coords..

offset = (list (* halfheight aspectRatio) halfheight)
what is it mean?

I can't understand the logic.. [aspectRatio * halfheight] hmm......

anyway.. I can't understand the Logic but I got the nice Logic...

thank you...

kraz

  • Guest
Re: How you do get the Current Screen's Coordinate ??
« Reply #10 on: October 28, 2008, 09:49:49 PM »
ah................... finally... I got it.

it is just EQUATION..

viewctr is centerpoint of current screen..

and offset.. it is absolute distance of x , y from centerpoint to corner of screen.

and then...(mapcar '- viewctr offset) (mapcar '+ viewctr offset)....

the logic is very easy...but the source is very difficult....
hmm... i was silly......

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: How you do get the Current Screen's Coordinate ??
« Reply #11 on: October 28, 2008, 10:08:47 PM »


Let me know what part(s) you don't understand and I'll (try to) advise.

:)

Nice!!
TheSwamp.org  (serving the CAD community since 2003)

DEVITG

  • Bull Frog
  • Posts: 481
Re: How you do get the Current Screen's Coordinate ??
« Reply #12 on: October 28, 2008, 10:15:04 PM »
As LAMBDA is a pending matter for me , I dig on the code and come with this other way to state it

Code: [Select]
(defun vp-coor ()

(setq screen-size (getvar "screensize"));_ Stores current viewport size in pixels (X and Y).
(setq screen-ratio ( / (car screen-size) (cadr screen-size)))
(setq view-size (getvar "viewsize"));_ Stores the height of the view in the current viewport. Expressed in drawing units.
(setq half-view-size ( * 0.5 view-size))
(setq view-ctr (getvar "viewctr"));_Stores the center of view in the current viewport. Expressed as a UCS coordinate.
(setq off-set (list  ( * half-view-size screen-ratio) half-view-size))

(setq vp-cords ( list ( mapcar '- view-ctr off-set) ( mapcar '+ view-ctr off-set)))

)

 Of course it maybe take a lot of recurses , but it can be a way to understand the LAMBDA function , also the variables shall be set to LOCAL .



Location @ Córdoba Argentina Using ACAD 2019  at Window 10

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: How you do get the Current Screen's Coordinate ??
« Reply #13 on: October 29, 2008, 12:34:17 AM »
ah................... finally... I got it ...
Glad you figured it out. :)

the logic is very easy...but the source is very difficult ...
Sorry. It was penned in a thread that challenged to solve that particular problem without using setq. Wasn't deliberately trying to make it obfuscated, tho I suppose the superfluous use of lambda can give that impression.

Nice!!
Thanks Mr.T. :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

patpower

  • Mosquito
  • Posts: 1
Re: How you do get the Current Screen's Coordinate ??
« Reply #14 on: December 01, 2022, 02:02:07 PM »
Hi!
Thanks for this coding, but what if I want to get the farthest x coordinate to be sure to paste far enough to not be over something... I see the coord but I would like to use it in my code... I want to do a zoom extend in my lisp and then get the coord (x axis) and then paste my stuff at that coord (+ an offset). Is it possible to extract those coords in variable?
Thanks!

BIGAL

  • Swamp Rat
  • Posts: 1429
  • 40 + years of using Autocad
Re: How you do get the Current Screen's Coordinate ??
« Reply #15 on: December 01, 2022, 09:34:33 PM »
Super simple two variables EXTMAX and EXTMIN. (getvar 'extmax)
A man who never made a mistake never made anything