Very often we work in multiple viewports, either tiled or non-tiled something like
THISIt became a desire to be able to swap one view for another as we worked through a model. As some of you may remember I had a strange little function to slice DVIEW sections of a model, for which ruul morawetz had helped build a viewport selection tool. Using that strange little tool, and the VIEW SAVE command I hacked up the following.
;; VPSWAP - swaps two viewports using VIEW SAVE and a sub-routine
;- ----------------------------------------------------------------
;; Sub-routine DVT:RM:CVPC is a strange little viewport selection function developed
;; for me by ruul morawetz in the AutoDESK forums for use in a DVIEW clipping routine
;- ----------------------------------------------------------------
;; NO RIGHTS RESERVED;
;; Any and all content may reproduced by any method on any medium for any reason.
;; Please, feel free to use, borrow, steal, claim as own, any part for any reason at
;; any time. Just don’t connect it to me. If by some chance, someone wishes to be
;; credited for something I’ve overlooked, please inform me immediately.
;- ----------------------------------------------------------------
;; Randall Culp - Falcon Design Services, Bridge City, Texas
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun c:VPsWap ()
(command ".undo" "BEGIN")
(if
(= (getvar "cvport") 1)
(command "_mspace")
)
(command "_view" "_d" "vpswap*") ;;;;Delete any existing vport views
(prompt "\nSelect a DIFFERENT viewport") ;;;;Get the first viewport
(dvt:rm:cvpc) ;;;;Viewport select tool;; subroutine below
(setq vprt01 (getvar "cvport")) ;;;;Get viewport setvar
(command "_view" "_S" "vpswap01") ;;;;Save the view of that viewport
(prompt "\nSelect another viewport") ;;;;Get the second viewport
(dvt:rm:cvpc) ;;;;Viewport select tool;; subroutine below
(setq vprt02 (getvar "cvport")) ;;;;Get viewport setvar
(command "_view" "_S" "vpswap02") ;;;;Save the view of that viewport
(setvar "cvport" vprt01) ;;;;Set first viewport
(command "_view" "r" "vpswap02") ;;;;Restore Second View
(setvar "cvport" vprt02) ;;;;Set second viewport
(command "_view" "r" "vpswap01") ;;;;Restore first View
(command "_view" "_d" "vpswap*") ;;;;Delete any existing vport views
(command ".undo" "END")
(princ)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun dvt:rm:cvpc ( / grrd weida p pold viewsize trigger)
(setq weida T viewsize (getvar "VIEWSIZE")
trigger (* viewsize 0.4)) ; adjust factor according to mouse speed etc
(while weida
(setq grrd (grread T )) ;(+ 1 2 4 8) 2
(cond
((= 5 (car grrd))
(setq p (cadr grrd))
(cond
((and pold (> (distance p pold) trigger))
(setq weida nil)
)
)
(setq pold p)
)
((= 2 (car grrd))(setq weida nil))
(T nil
)
)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Now to my question. There must be a more elegant solution, does anyone have any ideas?