Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello. Im trying to write a program that creates a viewport, then zooms the viewport to specific coordinates in model space. Im not concerned with the viewport scale. I want it to zoom to the coordinates no matter the size of the viewport that is drawn. I have everything working except for the zoom part. I did some research and tried a piece of code to attempt the zoom but it didnt work. This program is something I use for drawing a viewport, then setting the scale (you can see the scale line commented out). Id like to modify it to do this zoom thing. Thanks for any help.
(defun c:VPMAP (/ DS2 MYTILE P1 P2 USERLAYER USERVIEW VPS) (GV) (vl-load-com) (DEFUN *ERROR* (ERRMSG) (IF (/= ERRMSG "Function cancelled") (PRINC "\n Something failed...") (VL-CMDF "_.undo" "_e"))) (SETVAR 'CLIPROMPTUPDATE 0) (SETVAR 'NOMUTT 1) ;===================Turn off command line responses============== (setvar 'CMDECHO 0) ;DO NOT CHANGE THIS LINE ;========================================================= (COMMAND "_.undo" "_be") (setvar 'CLAYER "VP") (setq userlayer (getvar 'clayer) ds2 (getvar 'dimscale) userview (getvar 'ctab) ) (PRINC "\n\t CREATE VIEWPORT W/ZOOM TO MAP :: BEGIN \n") (vl-cmdf "mview" (setq p1 (getpoint "\n Select first corner of window opening: ")) (setq p2 (getcorner p1 "\n Select opposite corner of window opening: "))) (IF (AND (= 0 (GETVAR 'TILEMODE)) (= 1 (GETVAR 'CVPORT))) (VL-CMDF "._MSPACE")) (SETVAR 'CLIPROMPTUPDATE 1) (SETVAR 'NOMUTT 0) (PROGN (setq VPS (ssget "X" (list '(0 . "VIEWPORT") '(8 . "VP") (cons 410 userview)))) ; Get all viewports on "viewport" layer and current sheet layout (setq center (vlax-3d-point '(0.0 19.8 0.0)) width 20.0 height 20.0) ; (vla-put-customscale (vlax-ename->vla-object (ssname VPS 0)) (/ 1 96.0)) ; set veiwport scale to 1/96 (VL-CMDF PAUSE) ; pause for enter press ) (VL-CMDF "._PSPACE") (setvar 'psltscale 0) (PRINC "\n DIMSCALE returning to original setting. \n") (setvar 'dimscale ds2) ;===================Turn on command line responses============== (setvar 'CMDECHO 1) ;DO NOT CHANGE THIS LINE ;====================================================== (PRINC "\n Returning view and layer.....") (setvar 'ctab userview) (setvar 'clayer userlayer) (PRINC "\n View and layer returned! \n") (PRINC "\n\t CREATE VIEWPORT FOR MAP :: END \n") (VL-CMDF "_.undo" "_e") (SV) (PRINC) (PRINC) )
Solved! Go to Solution.