Jump to content

Recommended Posts

Posted

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

Posted

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
Posted
(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
Posted

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)

Posted

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 4
Posted

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)

  • 10 months later...
Posted
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

 

Posted (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 by mhupp
  • Like 1
Posted (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 by 3dwannab
Posted

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:

Mister Lee Mac

I could modify the lisp so that when it runs it saves the view that it has at that moment, and does not always save the same view when it is run for the first time, I hope I made myself clear, greetings

 

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...