Author Topic: Swapping VIEWPORTS?  (Read 6143 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
Swapping VIEWPORTS?
« on: February 06, 2004, 11:15:29 AM »
Has anyone written or seen a routine for swapping viewports??

Working in 3D, I use one large viewport on the right side of the screen and 3 smaller viewports stacked vertically on the left side. It'd be real handy to be able to swap the viewports around by picking them.

This is my hack job so far, I'm sure you guys can come up with something considerably more elgant.

Code: [Select]

;VPSWAP - Swap views between viewports
;------------------------------------------------------------------
(defun c:VPSwap ()
(command ".undo" "BEGIN")
(command "_view" "_d" "vpswap*")            ;;;;Delete any existing vport views

(prompt "\nSelect a DIFFERENT viewport")    ;;;;Get the first viewport
(dvs: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
(dvs: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)
)
;;;;;;;;;;;;;;;;;;;;;;;;;
;------------------------------------------------------------------
; ruul 03/11/11 - Crazy ViewPort Change
; adjust trigger if needed
; endless loop until clicked in another viewport
; if trigger isn't sufficient, enter also breaks the loop
(defun dvs: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
         )
      )
   )
)

CADaver

  • Guest
Swapping VIEWPORTS?
« Reply #1 on: February 10, 2004, 09:54:06 AM »
No takers???  Gee, if I had feelings, I'd be feeling ignored.   :cry:

daron

  • Guest
Swapping VIEWPORTS?
« Reply #2 on: February 10, 2004, 09:58:34 AM »
Sorry, saw it but thought others might be willing to help. I'm not sure what you're trying to do, but I'll take a look at the lisp and see if I can figure anything out.

daron

  • Guest
Swapping VIEWPORTS?
« Reply #3 on: February 10, 2004, 10:17:45 AM »
I'm not exactly sure what you're trying to accomplish, but I ran it in two instances. One with only a single viewport MS and one with three vports MS. You really should do something about the single vport problem. It locks up. As far as multi-views, it seems that if the program were more intuitive, i.e. reacted to the event of moving from one vport to another, you'd have a better program. Reason: it seems that you expect your users to type this command out before they switch viewports. That'll never happen. What I'm getting at? I wonder if the vba'ers wouldn't be able to take this and convert it (or help you convert it) to vba and place error handlers on it so that it'll work in the background and you nor your users will ever have to think about typing a command or hitting a button before switching viewports.

CADaver

  • Guest
Swapping VIEWPORTS?
« Reply #4 on: February 10, 2004, 12:07:59 PM »
Single viewport... good catch, I almost never have a single viewport, so it didn't even cross my mind.

What do I have in mind??  Aside from ... er... nevermind.

Working with large 3D models with DVIEW clipped views, typically we'll have 4 viewports (tilemode=1) one big one to the right, and 3 "stacked" vertically to the left.  Each with a different view of the model.  Currently we use a slightly automated VIEW SAVE/RESTORE function to bring up specific views for editting, it would be nice to just swap existing views from a little viewport to a larger one.

VBA??  I'm still working on that... gee who am I kiddin', I'm still learning lisp..

daron

  • Guest
Swapping VIEWPORTS?
« Reply #5 on: February 10, 2004, 12:16:55 PM »
Code: [Select]
VBA?? I'm still working on that... gee who am I kiddin', I'm still learning lisp..
Aren't we all. The only reason I'd suggest vba is because it's far easier and more stable to make autocad react to events in vba than in lisp, but if your users are looking to change views, I think you are on the right track.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Swapping VIEWPORTS?
« Reply #6 on: February 10, 2004, 12:38:33 PM »
- CADaver
perhaps you could upload a sample dwg to the lilly.pond for us to look at. I still am not sure what you are trying to do.
TheSwamp.org  (serving the CAD community since 2003)

SMadsen

  • Guest
Swapping VIEWPORTS?
« Reply #7 on: February 10, 2004, 02:04:21 PM »
Quote from: CADaver
No takers???  Gee, if I had feelings, I'd be feeling ignored.   :cry:
Sorry, but the avatar clearly says, "Ignore me"

daron

  • Guest
Swapping VIEWPORTS?
« Reply #8 on: February 10, 2004, 02:24:02 PM »
Man! I must've missed that avatar.

CADaver

  • Guest
Swapping VIEWPORTS?
« Reply #9 on: February 10, 2004, 05:20:22 PM »
Quote from: Daron
Man! I must've missed that avatar.


I think he's refering to my Glock 19 and 17L avatar.   :shock:

CADaver

  • Guest
Swapping VIEWPORTS?
« Reply #10 on: February 10, 2004, 05:33:50 PM »
Quote from: Mark Thomas
- CADaver
perhaps you could upload a sample dwg to the lilly.pond for us to look at. I still am not sure what you are trying to do.


All I have handy right now are huge, I'll trim one down a little and post later.

daron

  • Guest
Swapping VIEWPORTS?
« Reply #11 on: February 10, 2004, 05:35:07 PM »
Ah! Yes, they do seem to say that, don't they.

CADaver

  • Guest
Swapping VIEWPORTS?
« Reply #12 on: February 10, 2004, 07:12:17 PM »
Quote from: Daron
Ah! Yes, they do seem to say that, don't they.

hmmm...  the 19 might say that, but the 17L is a competition target piece.

oh well...   :wink:   It's not the last resort, just the last one I use.


~~~~~~~~~~~~~~~~~~~~~


ANyway, I've posted TOWER.DWG to the LilyPad:

http://theswamp.org/lilly.pond/CADaver/tower.dwg

When you open the file, you'll see 7 viewports (tilemode=1), one big one on the right and six little ones on the left.  Notice that some of the views residing in those viewports are DVIEW clipped.  I usually work in the big viewport building stuff, using the little viewports for point filters and the like or just a different perspective.

Now as I'm workin', I sometimes want to trade views from the little viewport to the larger (including dview settings), hence my feeble attempt.   Hope that clarifies it some.