Steven P Posted December 30, 2023 Share Posted December 30, 2023 Having end-of-year brain fog, does anyone know how to record the current view / display / zoom area or coordinates? So I might record the current area - perhaps the lower left / upper right coordinates of what is shown on the screen, The LISP might then zoom to objects (more than one), perhaps to select something, to highlight something or otherwise, user does stuff, LISP zooms to another area, user does more stuff. At the end of the LISP doing stuff it returns the view to what it was when the command started. An example might be: (user is zoomed into room 1) "Select a piece of equipment in Room 1" - LISP Zooms to room 1 "Select insert point, Room 2" - LISP Zooms to room 2 .... and so on rooms, 3, 4, 5 etc. - End of selecting insert point - LISP Zooms back to room 1 as it was before LISP was started. (probably easy get current coordinates of the view?) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 30, 2023 Share Posted December 30, 2023 Try this, using getvars VIEWCTR X= 55522.1809 Y= 63040.4178 Z= 0 (Read Only) VIEWSIZE 18655.3206 (Read Only) commands ZOOM C pt Scale ZOOM C viewctr viewsize You could make continuous variables as a list (roomnum 55522.1809 63040.4178 18655.3206) maybe save as Ldata then can zoom room 2. Ldata supports saving a list. (VLAX-PUT-LDATA "STEVEN" "view" rooms) (VLAX-GET-LDATA "STEVEN" "view") 1 1 Quote Link to comment Share on other sites More sharing options...
mhupp Posted December 30, 2023 Share Posted December 30, 2023 (setq vc (getvar 'viewctr)) (setq sz (getvar 'viewsize)) .... (setq Drawing (vla-get-activedocument (vlax-get-acad-object))) (vla-zoomcenter Drawing VC SZ);recal zoom location vla way 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted December 31, 2023 Author Share Posted December 31, 2023 Perfect, thanks Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 31, 2023 Share Posted December 31, 2023 There is also vla-zoomprevious 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted December 31, 2023 Author Share Posted December 31, 2023 Thanks Lee, normally I'd do that but the user might scroll around the screen a bit making selections and whatever - then got to work out how many 'previous' to zoom to (unless there is something in there I don't know yet) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 31, 2023 Share Posted December 31, 2023 The following offers another method using a temporary saved view - the advantage being that the user can adjust the view plane in addition to zooming & panning: (defun c:test ( / *error* doc idx obj vpo vwc vwn ) (defun *error* ( msg ) (if (and (= 'vla-object (type obj)) (vlax-write-enabled-p obj)) (vla-delete obj) ) (if (and msg (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))) (princ (strcat "\nError: " msg)) ) (princ) ) (setq doc (vla-get-activedocument (vlax-get-acad-object)) vwc (vla-get-views doc) idx 0 ) (while (itemp vwc (setq vwn (strcat "$temp" (itoa (setq idx (1+ idx))))))) (setq obj (vla-add vwc vwn) vpo (vla-get-activeviewport doc) ) (foreach prp '(center direction height target width) (vlax-put-property obj prp (vlax-get-property vpo prp)) ) (getpoint "\nPan & zoom around...") (vla-setview vpo obj) (vla-put-activeviewport doc vpo) (*error* nil) (princ) ) (defun itemp ( col key ) (not (vl-catch-all-error-p (vl-catch-all-apply 'vla-item (list col key)))) ) (vl-load-com) (princ) 2 Quote Link to comment Share on other sites More sharing options...
Steven P Posted December 31, 2023 Author Share Posted December 31, 2023 Nice, new years eve movie time here, I'll check it out 'next year' (till then, thanks for all your advice over the last year - to everyone - and have a good one next year) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.