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

0 Members and 1 Guest are viewing this topic.

mailmaverick

  • Bull Frog
  • Posts: 494
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: 494
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: 12922
  • 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 »

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: Coordinates of current Zoom Window
« Reply #15 on: April 01, 2014, 07:47:47 AM »
....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.

I had a yr of FORTRAN in college, thank god for IBM

There's one old college text book wouldn't be worth 10 cents today. (why do I still have it.)

Bhull1985

  • Guest
Re: Coordinates of current Zoom Window
« Reply #16 on: April 01, 2014, 08:24:47 AM »
Memories? :)

hmspe

  • Bull Frog
  • Posts: 362
Re: Coordinates of current Zoom Window
« Reply #17 on: April 01, 2014, 08:47:38 AM »
Memories.  Yes.  Hollerith cards.  IBM 370. Fortran.  T.A. who wrote 'goto' with slashed through the o's.  Business students in the study room in the dorm who struggled with basic math, and engineering students who would do their homework (in seconds) to get them to stop griping about how hard their homework was.... 
"Science is the belief in the ignorance of experts." - Richard Feynman

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #18 on: April 01, 2014, 01:22:19 PM »
From Express Tools:

Code: [Select]
(ACET-GEOM-VIEW-POINTS)
Will return a list Lower Left and Upper Right as 3d points.

Code: [Select]
((3737.61 598.711 0.0) (10595.1 3058.81 0.0))
Timing for 1 000 000 repetitions:
Quote
ACET                      Elapsed: 1.528 sec.
ve                          Elapsed: 9.859 sec.
LM:ViewportExtents  Elapsed: 9.813 sec.
vpcords                  Elapsed: 9.891 sec.
« Last Edit: April 01, 2014, 01:42:10 PM by ymg »

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Coordinates of current Zoom Window
« Reply #19 on: April 01, 2014, 01:40:58 PM »
express tools, meh
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #20 on: April 01, 2014, 01:46:42 PM »

Quote
express tools, meh

 :lmao: Have to agree with you, it is a mixed bag.

ymg

hmspe

  • Bull Frog
  • Posts: 362
Re: Coordinates of current Zoom Window
« Reply #21 on: April 01, 2014, 02:42:51 PM »
But it is very simple code:

Code: [Select]
(defun acet-geom-view-points ( / a b c d x )
 (setq b (getvar "viewsize")
       c (car  (getvar "screensize"))
       d (cadr (getvar "screensize"))
       a (* b (/ c d))
       x (trans (getvar "viewctr") 1 2)
       c (list (- (car  x) (/ a 2.0))
               (- (cadr x) (/ b 2.0))
               0.0
         )
       d (list (+ (car  x) (/ a 2.0))
               (+ (cadr x) (/ b 2.0))
               0.0
         )
       c (trans c 2 1)
       d (trans d 2 1)
 )
 (list c d)
)
"Science is the belief in the ignorance of experts." - Richard Feynman

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #22 on: April 01, 2014, 03:04:35 PM »
hmspe,

no need to define it if you have Express Tool installed.

Believe it is part of aceutil.fas

All you need is:
Code: [Select]
(setq vext (ACET-GEOM-VIEW-POINTS))
ymg

hmspe

  • Bull Frog
  • Posts: 362
Re: Coordinates of current Zoom Window
« Reply #23 on: April 01, 2014, 05:11:33 PM »
ymg,

I understand, but there are those who either do not have express tools or will not use express tools because they cannot be locally maintained or because they can't be sure everyone has them installed.
"Science is the belief in the ignorance of experts." - Richard Feynman

danallen

  • Guest
Re: Coordinates of current Zoom Window
« Reply #24 on: April 01, 2014, 05:42:24 PM »
or on Bricscad!

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: Coordinates of current Zoom Window
« Reply #25 on: April 01, 2014, 06:15:30 PM »
lee,

I like the:

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

ymg

Thanks ymg  :-)

ymg

  • Guest
Re: Coordinates of current Zoom Window
« Reply #26 on: April 02, 2014, 08:59:30 AM »
@danallen,

Express Tools for Bricscad can be downloaded here: http://www.bricsys.com/common/applications/application.jsp?app=589

@hmspe,

I certainly do not advocate the use of acet for everything.  I was merely showing the possibilities.

As for the installed base, most everybody has them.

What is more of a problem is that documetation for them is kind of sparse,
plus some of the functions are less than ideal.  So your mileage may (will) vary.

ymg




Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Coordinates of current Zoom Window
« Reply #27 on: April 02, 2014, 09:03:16 AM »
< ..>

What is more of a problem is that documentation for them is kind of sparse,
plus some of the functions are less than ideal.  So your mileage may (will) vary.

ymg

That covers the issue very well, I think.
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.