Author Topic: Copying, Exploding or Changing Viewports in Model Space  (Read 16104 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« on: October 01, 2004, 06:07:01 PM »
OK,

This is a weird request but I do hope it is possible.

I created a macro that will copyclip a viewport out of paper and pasteclip it into Model scaled up at the respective scale in the macro. This is a cool way for me to define my limits to which I can draw in Model. For example, if I am going to plot at 1/4"=1' then I will have the viewport scale to a factor of 48 and so on.

Anyhow, this concept works great except one thing. In order to copy the viewport, you need to use copy and pasteclip.

My question is, is there a way to either explode that VP, copy it using AutoCAD's standard copy command or possibly convert it into some other geometry like a rectangle?

Hope there is an answer?

Thanks

Mark

danny

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #1 on: October 01, 2004, 06:44:10 PM »
I use this
Code: [Select]
;draws Pspace / viewport Limits in Mspace on defpoints layer
               ;VPLIM.lsp draws the limits of a Paperspace Viewport Boundary in MODELSPACE
               ;VP - Get ViewPort object
               ;HT - Get Outside HeighT of Viewport
               ;WD - Get Oustide WiDth of Viewport
               ;VN - Get Viewport Number
               ;CTR - Get CenTeR of Viewport
               ;CTRX - Caluculate X of Viewport CenTeR
               ;CTRY - Caluculate Y of Viewport CenTeR
               ;VS - Get View Size of viewport
               ;XP - Calculate XP factor of viewport
               ;IW - Calculate Width of viewport
               ;BL - Calculate Bottom Left corner of viewport
               ;BR - Calculate Bottom Right corner of viewport
               ;TR - Calculate Top Right corner of viewport
               ;TL - Calculate Top Left corner of viewport
               ;PW - Save PlineWid
               ;OS - Save OSmode



               ;start function and define variables
(defun
     C:VPL
          (/ VP HT   WD VN CTR CTRX CTRY VS XP IW BL   BR TR TL PW OS)

               ;turn off command echoing
  (setvar "cmdecho" 0)

               ;save current layer as "clay"
  (setq clay (getvar 'clayer))

               ;make current layer defpoints
  (command "_.layer" "m" "Defpoints" "")

               ;enter pspace
  (command ".pspace")

               ;select viewport boundary
  (setq   VP
    (entget
      (car
        (entsel
          "\nSelect Viewport to Draw Boundary
             in "
        ) ;_ end of entsel
      ) ;_ end of car
    ) ;_ end of entget
  ) ;_ end of setq

               ;Get Viewport height with
  (setq HT (cdr (assoc 41 VP)))

               ;Get Viewport width with
  (setq WD (cdr (assoc 40 VP)))

               ;Get Viewport Number
  (setq VN (cdr (assoc 69 VP)))

               ;enter mspace
  (command ".mspace")

               ;set correct viewport
  (setvar "cvport" VN)

               ;set UCS to View
  (command ".ucs" "v")

               ;Get VIEWCTR store as CTR
  (setq CTR (getvar "viewctr"))

               ;Get X of CTR
  (setq CTRX (car CTR))

               ;Get Y of CTR
  (setq CTRY (cadr CTR))

               ;Get inside Viewport height
  (setq VS (getvar "viewsize"))

               ;Get XP Factor with HeighT / View Size
  (setq XP (/ HT VS))

               ;Get inside width of Viewport by
  (setq IW (* (/ VS HT) WD))

               ;Find four corners of Viewport
  (setq BL (list (- CTRX (/ IW 2)) (- CTRY (/ VS 2))))

  (setq BR (list (+ CTRX (/ IW 2)) (- CTRY (/ VS 2))))

  (setq TR (list (+ CTRX (/ IW 2)) (+ CTRY (/ VS 2))))

  (setq TL (list (- CTRX (/ IW 2)) (+ CTRY (/ VS 2))))

               ;Save current pline width
  (setq PW (getvar "plinewid"))

               ;Set Pline width to zero
  (setvar "plinewid" 0)

               ;Save current osmode
  (setq OS (getvar "osmode"))

               ;Draw pline inside border
  (command ".pline" BL BR TR TL "c")

               ;Restore pline width back
  (setvar "plinewid" PW)

               ;Restore UCS back
  (command ".ucs" "p")

               ;Restore osmode
  (setvar "osmode" OS)

               ;Restore curernt layer
  (setvar "clayer" clay)

               ;Clean up command prompt
  (princ)

               ;Go Back To Papserspace
  (command ".pspace")

)

ML

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #2 on: October 01, 2004, 06:54:53 PM »
LOL

Hey Danny,

I really do appreciate it but Iwas looking for something real simple.
I know some VBA and a very little Lisp but the people I work with want it nice and easy. I guess I am looking ffor a way without going to code


Thanks

Mark

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Copying, Exploding or Changing Viewports in Model Space
« Reply #3 on: November 15, 2004, 10:22:24 PM »
Maybe I don't understand the problem, but I just activate the viewport and draw a rectangle
in model space the size of the viewport.  :?:
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Serge J. Gianolla

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #4 on: November 15, 2004, 11:04:29 PM »
Ciao CAB, how's things? If I understand his issue [that remains to be seen!!  :D ], the problem with copy'nPasting a viewport in MS means that this is still a viewport - though it looks like a rectangle. Incidentally, for users who want a rectangle acting like a rectangle as opposed to a de facto polyline, this is the way to go around AutoCAD's limitation: Make a viewport in PS, cut'nPaste in MS, then have fun with changeProperties to edit width and height!
Sorry for digressing Mark, I remember seeing in dim past, a lisp routine for rel14 that was "imprinting the viewport in MS [in other word creating the exact rectangle in MS] but was limited to rectangular viewports - obviously because polygonal viewports came with 2000. Do some google search, I'll try to find it in my ever increasing bricabrac!

CADaver

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #5 on: November 16, 2004, 07:54:18 AM »
Draw a rectangle in PS on top of the viewport then use CHSPACE out of Express Tools.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Copying, Exploding or Changing Viewports in Model Space
« Reply #6 on: November 16, 2004, 09:04:24 AM »
Quote from: CADaver
Draw a rectangle in PS on top of the viewport then use CHSPACE out of Express Tools.

Could it be that easy?
Wow, Thanks CADaver. :shock:

Hay Serge, good to see you...
I've reached the age where the happy hour is a nap. ()
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ML

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #7 on: November 16, 2004, 09:06:52 AM »
I am curently working my way through VBA
Eventually I will just be able to write whatever comes to mind.

For now, I still cling to plain old menu macros to a large degree and I don't know much about LISP, otherwise I would just tweak a few routines I have seen

Serge, you did nail the problem of the head. I don't mind the block reference in Model (as long as no one explodes it) but inevitably someone will explode it. Also, note that you can not copy viewports in Model. My Viewport is on Defpoints and color blue, I wanted it to be green after pasted to Modelspace

Mark

CADaver

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #8 on: November 16, 2004, 10:51:01 AM »
Quote from: CAB
Quote from: CADaver
Draw a rectangle in PS on top of the viewport then use CHSPACE out of Express Tools.

Could it be that easy?
Wow, Thanks CADaver. :shock:



Button macro:
Code: [Select]
^C^Cpspace;-layer;m;defpoints;;rectang;end;\end;\chspace;l;;

ML

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #9 on: November 16, 2004, 11:53:39 AM »
LOL, I didn't try it yet!  :)

ML

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #10 on: November 16, 2004, 12:01:57 PM »
Ok, that is a real cool macro BUT
I would still prefer to click on the viewport and have it make a polyline in MSPACE for me.

Or if I can pick the viewport and it then creates the PL in Model for me scaled up.

I don't want to get into picking points for this one. I think it will discourage people from using it.

I amy be able to follow that same macro principal and acheive it

Anymore suggestions?

Thank you

Mark

CADaver

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #11 on: November 16, 2004, 12:42:47 PM »
Lesee...

Group codes
10 is the PS viewport center
40 is the PS viewport width
41 is the PS viewport height
45 is the MS viewport width

The viewport scale would be group_41 / group_45

Looks do-able in lisp. What am I missing?

daron

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #12 on: November 16, 2004, 02:27:14 PM »
The fact that he only desires to know vba. I think you still need those group code for vba too. I could be wrong, though.

CADaver

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #13 on: November 16, 2004, 03:12:12 PM »
Quote from: Daron
The fact that he only desires to know vba. I think you still need those group code for vba too. I could be wrong, though.


ah, missed that.

Serge J. Gianolla

  • Guest
Copying, Exploding or Changing Viewports in Model Space
« Reply #14 on: November 16, 2004, 06:20:29 PM »
Quote

 Also, note that you can not copy viewports in Model.

Correct Mark, but if you cut'nPaste as a block then it can be copied, mirrored, arrayed... and then they can be exploded to viewports. The viewport itself cannot be exploded to its primitives.