Jump to content

Record current modelspace zoom


Steven P

Recommended Posts

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?)

Link to comment
Share on other sites

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")

 

  • Like 1
  • Agree 1
Link to comment
Share on other sites

(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

 

  • Like 1
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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)

 

  • Like 2
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...