ziele_o2k Posted February 13, 2019 Share Posted February 13, 2019 (edited) Hi all, Maybe someone know better lisp (without command) that will save current view and restore it. (defun c:foo ( / pz:SaveView pz:RestoreView *pz:Model-p old_cmd ) (setq old_cmd (getvar 'cmdecho)) (setvar 'cmdecho 0) (defun pz:SaveView nil (if (= (getvar 'ctab) "Model") (setq *pz:Model-p T) ) (command "_view" "_save" "TMP_VIEW_PZ") ) (defun pz:RestoreView nil (if *pz:Model-p (setvar 'ctab "Model")) (command "_view" "_restore" "TMP_VIEW_PZ") (command "_view" "_delete" "TMP_VIEW_PZ") ) ;save current view (pz:SaveView) ;; do something (if (= (getvar 'ctab) "Model") (setvar 'ctab (car (layoutlist))) (setvar 'ctab "Model") ) (alert "Current tab switched") ;restore current view (pz:RestoreView) (alert "Current tab and view restored to previous") (setvar 'cmdecho old_cmd) (princ) ) Edited February 13, 2019 by ziele_o2k Quote Link to comment Share on other sites More sharing options...
lido Posted February 14, 2019 Share Posted February 14, 2019 First check if CVPORT=2 (Model space or Model space window active in Paper space). Try this: (setq ACDC (vla-get-activedocument (vlax-get-acad-object)) ;;Save View ViewObj (vla-add (vla-get-views ACDC) (itoa (getvar "MILLISECS"))) ;;Save VPort AcVp (vla-get-activeviewport ACDC) ;;Save VPort characteristics OldCen (vla-get-center AcVp) OldDir (vla-get-direction AcVp) OldHgt (vla-get-height AcVp) OldWid (vla-get-width AcVp) ) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; YOUR CODE HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Restore View (vla-put-direction ViewObj OldDir) (vla-put-center ViewObj OldCen) (vla-put-height ViewObj OldHgt) (vla-put-width ViewObj OldWid) (vla-setview AcVp ViewObj) (vla-put-activeviewport ACDC AcVp) ;;Delete View (vla-delete ViewObj) Quote Link to comment Share on other sites More sharing options...
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.