Author Topic: Swapping views in Viewports  (Read 2280 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
Swapping views in Viewports
« on: November 02, 2004, 06:48:52 PM »
Very often we work in multiple viewports, either tiled or non-tiled something like THIS

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


Code: [Select]
;; 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?

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Swapping views in Viewports
« Reply #1 on: November 02, 2004, 07:17:38 PM »
I don't want to take all the fun away from you so consider ...

vla-get-views
vla-add
vla-setview
...

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

CADaver

  • Guest
Swapping views in Viewports
« Reply #2 on: November 02, 2004, 07:40:17 PM »
Quote from: MP
I don't want to take all the fun away from you so consider ...

vla-get-views
vla-add
vla-setview
...

:)

:(
arrrgggghhhh  VLA stuff again....  Man someday I gotta make time to learn all that.

Thanks Michael, I kinda scanned help for something on viewports but not views, so I missed both "get" and "set".