Steven P Posted December 30, 2023 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
BIGAL Posted December 30, 2023 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
mhupp Posted December 30, 2023 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
Steven P Posted December 31, 2023 Author 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
Lee Mac Posted December 31, 2023 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) 3 Quote
Steven P Posted December 31, 2023 Author 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
3dwannab Posted Sunday at 10:54 PM Posted Sunday at 10:54 PM On 12/30/2023 at 10:35 PM, mhupp said: (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 I needed this for a program I'm working on and I got the error below. Quote ; error: ActiveX Server returned the error: unknown name: ZoomCenter This is working: (setq acadObj (vlax-get-acad-object)) (setq vc (vlax-3d-point (getvar 'viewctr))) ;; CODE HERE..... (setq sz (getvar 'viewsize)) (vla-zoomcenter acadObj vc sz) ; Set back to the old zoom location Quote
mhupp Posted Sunday at 11:00 PM Posted Sunday at 11:00 PM (edited) You need (vl-load-com) at the start of the lisp. this will load vla commands. -edit if you have a start up lisp most people put it there only needs to run once but it dosen't hurt to have it at the start of lisp that use vla commands Edited Sunday at 11:02 PM by mhupp 1 Quote
3dwannab Posted Sunday at 11:05 PM Posted Sunday at 11:05 PM (edited) 5 minutes ago, mhupp said: You need (vl-load-com) at the start of the lisp. this will load vla commands. -edit if you have a start up lisp most people put it there only needs to run once but it dosen't hurt to have it at the start of lisp that use vla commands That wasn't the problem. It needed (vlax-get-acad-object) https://help.autodesk.com/view/ACD/2022/ENU/?guid=GUID-E916D642-DBCE-4186-8574-7B8D002BB7E1 Edited Sunday at 11:06 PM by 3dwannab Quote
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.