The ID of each viewport is stored in DXF code 69 (use ENTGET function to list).
Next use CVPORT system variable to activate a particular viewport.
Code:(command "_MSPACE") (setvar "CVPORT" 2)
Registered forum members do not see this ad.
Hi all,
I wonder if there is any method to "activate" a selected viewport using AutoLisp (rather not VLisp, cos I don't know any VLisp at all !!!)
for example if I draw a rectangle on a viewport in paper space and I want to transfer this rectangle into model space, I would use CAD command "chspace", but then I need to click on the particlar viewport so that the rectangle goes to the right place. Also if I want to make the viewport image to a particular scale, say 1:20, I also have to click into the viewport and type "zoom" "1/20xp".
What I cannot figure out is how I can use AutoLisp to "activate" a selected viewport.
Thank you so much
The ID of each viewport is stored in DXF code 69 (use ENTGET function to list).
Next use CVPORT system variable to activate a particular viewport.
Code:(command "_MSPACE") (setvar "CVPORT" 2)
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
There is also the VPORTS function that will list the viewports defined in a layout (1 is always Paper Space).
Code:;;; Cycle Through Viewports (05-VI-2012) (defun c:CTV( / oldCmdEcho listVPorts itemVPort ) (vl-load-com) (setq oldCmdEcho (getvar "CMDECHO")) (setvar "CMDECHO" 0) (if (/= (getvar "CTAB") "Model") (progn (setq listVPorts (vl-sort (vports) '(lambda(v1 v2) (< (car v1) (car v2))))) (if (> (length listVPorts) 1) (progn (command "_MSPACE") (foreach itemVPort (cdr listVPorts) (setvar "CVPORT" (car itemVPort)) (getkword "\nPress <ENTER> to go to next viewport") ) (command "_PSPACE") ) (prompt "\nThere are no viewports defined in this Layout!") ) ) (prompt "\nThis routine works only in Layout!") ) (setvar "CMDECHO" oldCmdEcho) (princ) )
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
great, it should solve my problems !!!
Thank you very much Msasu
You're entirely welcome!
Regards,
Mircea
AutoCAD's happy user equation: FILEDIA + PICKADD² + PICKFIRST = 3
Registered forum members do not see this ad.
Another method:
And to 'deactivate':Code:(defun c:vpon ( / d s ) (vl-load-com) (if (setq s (ssget "_+.:S:E:L" '((0 . "VIEWPORT")))) (progn (setq d (vla-get-activedocument (vlax-get-acad-object))) (vla-put-mspace d :vlax-true) (vla-put-activeviewport d (vlax-ename->vla-object (ssname s 0))) ) ) (princ) )
Code:(defun c:vpoff ( ) (vla-put-mspace (vla-get-activedocument (vlax-get-acad-object)) :vlax-false) (princ) )
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper
Bookmarks