Author Topic: Coordinates of current Zoom Window  (Read 9710 times)

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 493
Coordinates of current Zoom Window
« on: March 31, 2014, 04:36:22 AM »
How to get min and max coordinates of current window in ModelSpace ? Note that (getvar "EXTMAX") and (getvar "EXTMIN") gives max and min coordinates of extents of the drawing but my requirement is current zoomwindow .


roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Coordinates of current Zoom Window
« Reply #1 on: March 31, 2014, 04:48:06 AM »
You can use these sys. variables to calculate those points:
VIEWCTR
VIEWDIR
VIEWSIZE
VIEWTWIST
SCREENSIZE

And searching this forum for these vars will no doubt lead to code samples.

mailmaverick

  • Bull Frog
  • Posts: 493
Re: Coordinates of current Zoom Window
« Reply #2 on: March 31, 2014, 05:01:34 AM »
Thanks a lot.

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #3 on: March 31, 2014, 12:12:50 PM »
Try this:

Code - Auto/Visual Lisp: [Select]
  1. (defun ve (/ vc vh sz vw vq ll ur)
  2.   ;; = View Extents                                               ;
  3.   (setq vc (getvar 'viewctr)
  4.         vh (getvar 'viewsize)
  5.         sz (getvar 'screensize)
  6.         vw (* vh (/ (car sz) (cadr sz)))
  7.         vq (mapcar '/ (list vw vh) '(2 2))
  8.         ll (mapcar '- vc vq) ; Lower Left  corner of current view ;
  9.         ur (mapcar '+ vc vq) ; Upper Right corner of current view ;
  10.   )
  11.   (list ll ur)
  12. )
  13.  

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Coordinates of current Zoom Window
« Reply #4 on: March 31, 2014, 06:08:35 PM »
Pretty much the same method as ymg:

Code - Auto/Visual Lisp: [Select]
  1. ;; Viewport Extents  -  Lee Mac
  2. ;; Returns two WCS points describing the lower-left and
  3. ;; upper-right corners of the active viewport.
  4.  
  5. (defun LM:ViewportExtents ( / c h v )
  6.     (setq c (trans (getvar 'viewctr) 1 0)
  7.           h (/ (getvar 'viewsize) 2.0)
  8.           v (list (* h (apply '/ (getvar 'screensize))) h)
  9.     )
  10.     (list (mapcar '- c v) (mapcar '+ c v))
  11. )

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #5 on: March 31, 2014, 06:50:52 PM »
lee,

I like the:

Code: [Select]
(apply '/ (getvar 'screensize))
Neat!

ymg

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Coordinates of current Zoom Window
« Reply #6 on: March 31, 2014, 07:13:06 PM »
That looks rather MP'ish.
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.

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #7 on: March 31, 2014, 07:55:02 PM »
Kerry,

Quote
That looks rather MP'ish.

Don't know if you are referring to the bit of code up there.

It could be because I don't know where it came from, had it lying in the library.

ymg

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Coordinates of current Zoom Window
« Reply #8 on: March 31, 2014, 10:07:25 PM »
I was referring to the snippet
Code - Auto/Visual Lisp: [Select]
  1. (apply '/ (getvar 'screensize))

I agree it's  very neat.
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Coordinates of current Zoom Window
« Reply #9 on: March 31, 2014, 10:21:59 PM »
That looks rather MP'ish.

Wow Kerry, good eye. From a little over 9 years ago (last line of logic):

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"))
        )
    )
)

That said, once you achieve competence in LISP the odds one's approach will appear similar to another is rather high, so I doubt Lee lifted it from me. To wit, odds are Reni or Tony wrote something using a construct like I penned above 142 years before I did.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Coordinates of current Zoom Window
« Reply #10 on: March 31, 2014, 10:35:33 PM »
No suggestion of 'lifting'. Just an acknowledgment of the frugality of that snippet.

I recognise better than most the likelihood of similarity ... I've been looking at this language for a long time.

added:
Regarding the 142 years  .. I'm older than Lisp so I call 'poetic licence' :)
« Last Edit: March 31, 2014, 10:43:20 PM by Kerry »
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Coordinates of current Zoom Window
« Reply #11 on: March 31, 2014, 10:45:28 PM »


Added: Do I get points for being the same age as LISP?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Coordinates of current Zoom Window
« Reply #12 on: March 31, 2014, 10:53:32 PM »

of course ... anyone who survived the 60's gets bonus points in my book.
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.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Coordinates of current Zoom Window
« Reply #13 on: March 31, 2014, 11:08:26 PM »
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Bhull1985

  • Guest
Re: Coordinates of current Zoom Window
« Reply #14 on: April 01, 2014, 07:17:46 AM »
weirdest/funniest off topic posts ive read in a long time, kudos :) (and the gifs)







p.s.
....old people, hehe! To make this more relevant you all aren't so old, my grandfather was programming military systems in fortran in the 50's and 60's. You were yipper-snappers then I bet :D



p.s.s. I think old is just another word for "experienced"
« Last Edit: April 01, 2014, 07:24:04 AM by Bhull1985 »