TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Grrr1337 on January 17, 2018, 10:52:31 AM

Title: Store Zoom coordinates
Post by: Grrr1337 on January 17, 2018, 10:52:31 AM
Hi guys, heres the thing:

I've recently wrote some subfunction to change the zoom(focus) on a list of graphical objects, that is being used along with grread (thats my #main).
So it utilises the following subfunction:
Code: [Select]
; Zooms on and highlights using grdraw / grvecs in order to focus on the target object
; (FocusOnObj (vlax-ename->vla-object (car (entsel))) 0.9)
(defun FocusOnObj ( o zv / cad ll ur ul lr L )
  (cond
    ( (not (eq 'VLA-OBJECT (type o))) nil)
    ( (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-GetBoundingBox (list o 'll 'ur))))
      (setq cad (vlax-get-acad-object))
      (vla-ZoomWindow cad ll ur)
      (vla-ZoomScaled cad (cond (zv)(1)) acZoomScaledRelative)
      (mapcar 'set '(ll ur) (mapcar 'vlax-safearray->list (list ll ur)))
      (setq ll (list (car ll) (cadr ll)))
      (setq ur (list (car ur) (cadr ur)))
     
      (setq ul (list (car ur) (cadr ll)))
      (setq lr (list (car ll) (cadr ur)))
      (setq L (list (list ll ul) (list ul ur) (list ur lr) (list lr ll)  ))
      (grvecs (apply 'append (mapcar '(lambda (x) (cons 1 x)) L)))
      ; (mapcar '(lambda (x) (apply 'grdraw (append x (list 1 3)))) L)
    )
  )
); defun FocusOnObj

However at the very begining I would like to initially  store the zoom coordinates so in the end I could reset with:
Code: [Select]
(vla-ZoomWindow cad ll ur)
So any ideas how I could obtain them from the current zoom?



Alternatively I could make a counter that would count how many times I'd have to invoke the ZoomPrevious method, but IMO thats relatively ineffective approach.
Title: Re: Store Zoom coordinates
Post by: ronjonp on January 17, 2018, 11:00:41 AM
This is how I do it:
Code: [Select]
(setq vsize (getvar 'viewsize)
      cpt   (getvar 'viewctr)
)
(vla-zoomcenter (vlax-get-acad-object) (vlax-3d-point cpt) vsize)
Title: Re: Store Zoom coordinates
Post by: Grrr1337 on January 17, 2018, 11:13:48 AM
Thanks Ron,
I just found this thread (http://www.theswamp.org/index.php?topic=46661.0), that contains the subfoo which I was actually looking for.
But your suggestion looks the simpliest, so I prefer it! :)
Title: Re: Store Zoom coordinates
Post by: ronjonp on January 17, 2018, 11:15:39 AM
Thanks Ron,
I just found this thread (http://www.theswamp.org/index.php?topic=46661.0), that contains the subfoo which I was actually looking for.
But your suggestion looks the simpliest, so I prefer it! :)
Glad to help :)
Title: Re: Store Zoom coordinates
Post by: MP on January 17, 2018, 11:38:10 AM
Thanks Ron ...
Glad to help :)

(http://ic.pics.livejournal.com/scapegoat1989/2550323/37515/37515_original.gif)
Title: Re: Store Zoom coordinates
Post by: ronjonp on January 17, 2018, 11:44:06 AM
Thanks Ron ...
Glad to help :)

(http://ic.pics.livejournal.com/scapegoat1989/2550323/37515/37515_original.gif)
LOL  ;D
Title: Re: Store Zoom coordinates
Post by: Grrr1337 on January 17, 2018, 11:59:00 AM
Thanks Ron ...
Glad to help :)

...

(http://i53.tinypic.com/1218r4m.jpg)

Cheers!  :lol: