Author Topic: Store Zoom coordinates  (Read 2291 times)

0 Members and 1 Guest are viewing this topic.

Grrr1337

  • Swamp Rat
  • Posts: 812
Store Zoom coordinates
« 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.
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Store Zoom coordinates
« Reply #1 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)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Store Zoom coordinates
« Reply #2 on: January 17, 2018, 11:13:48 AM »
Thanks Ron,
I just found this thread, that contains the subfoo which I was actually looking for.
But your suggestion looks the simpliest, so I prefer it! :)
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Store Zoom coordinates
« Reply #3 on: January 17, 2018, 11:15:39 AM »
Thanks Ron,
I just found this thread, that contains the subfoo which I was actually looking for.
But your suggestion looks the simpliest, so I prefer it! :)
Glad to help :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

ronjonp

  • Needs a day job
  • Posts: 7526

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

Grrr1337

  • Swamp Rat
  • Posts: 812
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg