I have been toying with the idea of writing a routine that would create named views and draw view boundary by selecting viewports.
Has this been done?
Any ideas?
Vlisp or Lisp?
Thanx - Rob
|
I have been toying with the idea of writing a routine that would create named views and draw view boundary by selecting viewports.
Has this been done?
Any ideas?
Vlisp or Lisp?
Thanx - Rob
Go to the AUGI Exchange and search for:
001015 DrawVpBorder.lsp - AutoLISP file to draw viewport outline in modelspace
and
001193 VPExtentsBox.zip - VBA sub draws a ms polyline to indicate the extents of a ps viewport
or you could use vp-outline.lsp by Jimmy Bergmark
Website: www.jtbworld.com
Tom,
Thanks for the info, this gives me a place to start.
Rob
I stumbled across this after trying to write my own lsp for this (I know where to start next time).
I tried both of the lsp programs recommended above. Neither work properly. They succeed in drawing the outline (for both simple rectangular and polygonal viewports), but not at the proper location, usually somewhere far away (near, but not equal to, the coordinate expressed in group code 12 for the viewport).
I'm guessing it's related to the trans function (which is see in those lsps) and converting the paperspace coordinates to model space, but I can't figure it out. (Something I couldn't do while writing my own lsp, either).
Anybody have any ideas?
Tom,Originally Posted by tom.wilshusen
I haven't taken the time to look at this, but I had the same thought, I believe the trans function to convert points obtained should fix this.
Rob
Thanks, Tim. I hope I'm not violating some policy by posting a reply here.
I tried your vg.lsp posted there. Works like a champ.... unless there are rotated dview viewports and other UCS in the viewport. Then I get the same thing as the others: rotated and displaced polylines. (I'm working on pipeline drawings with wide array of rotations and ucs's.)
Specifically, from my brief testing, your code performs as such:
-with a WCS in the viewport but a rotated dview, it will place the polyline in the proper location, but rotated to the WCS instead of the view.
-with a different UCS in the viewport and a rotated dview (to make the ucs appear horizontal), the created polyline is rotated and displaced.
It seems to simple to be so difficult.
I could have sworn that I tested it with rotated ucs, and it worked. It doesn't seem to work correctly on my system either. Let me do some testing, and see what I can come up with.
here's what is used around here.
Code:;VPVW.lsp draws the limits of a Paperspace Viewport Boundary in Modelspace, ;creates a view and attaches a hyperlink to a selected object in paperspace ;Written by Rob Hillier, Feb 27/06 ;modified version of vplim by Murray Clack ;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 ;MODIFICATIONS ;1. Added function to turn off "ucsfollow" - Sept 1/1999 ;load statement (prompt "\nVPLIM.lsp loaded. Enter VPV to execute ") ;alert statement ;;(alert "\nMake sure Viewport Boundary layer is On and Thawed! ") ;start function and define variables (defun c:VPV (/ FL VP HT WD CTR CTRX CTRY VS XP IW PW OS) ;turn off command echoing (setvar "cmdecho" 0) ;enter pspace (command ".pspace") ;select viewport boundary (setq VP (entget (car (entsel "\nSelect Viewport to Draw Boundary in ")))) ;select hyperlink object (setq hlo (cadr (entsel "\nSelect Hyperlink Object: "))) ;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) ;turn off UCSFOLLOW (setq FL (getvar "ucsfollow")) (setvar "ucsfollow" 0) ;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)))) ;get current layer (setq clayer (getvar "clayer")) (setq vplayer (tblsearch "layer" "defpoints")) (if (= nil vplayer) (command "layer" "m" "defpoints" "c" "7" "defpoints" "") (setvar "clayer" "defpoints")) ;Save current pline width (setq PW (getvar "plinewid")) ;Set Pline width to zero (setvar "plinewid" 0) ;Save current osmode (setq OS (getvar "osmode")) ;Turn off Osnaps (setvar "osmode" 0) ;Draw pline inside border (command ".pline" BL BR TR TL "c") (command "tilemode" 1) ;Create view (command "view" "w" vn bl tr) (command "tilemode" 0) ;Restore pline width back (setvar "plinewid" PW) ;Restore UCS back (command ".ucs" "p") ;Restore osmode (setvar "osmode" OS) ;Restore UCSFOLLOW (setvar "ucsfollow" FL) ;Clean up command prompt (princ) ;Go Back To Paperspace (command ".pspace") (command "-hyperlink" "I" "O" hlo "" "" VN "") (command "setvar" "clayer" clayer) );The End!
Last edited by Opie; 2006-03-29 at 07:32 PM. Reason: fixed code tag
Loyalty above all else except honor
For my honor is my life!
Here's a nice little lisp routine that when run in paperspace, it tells you the scale of the viewport and places a rectangle (defpoints layer) in model space showing the extents of the viewport. I didn't write it but I added to it.
I've had it and used it since ACAD R14.
It's simple and does the trick.
Ted
Hi Ted,
Sorry for the *edit*, but I believe it best if the file MVWGDE.LSP was not posted on the AUGI web site, unless the author author has given their permission.
AUGI can not take any chances with regard to Copyright infringements that may exist. It would be good manners to obtain the author's permission before posting their work.
Thanks for your understanding,
Richard
Forum Moderator
Last edited by Opie; 2006-03-31 at 04:47 PM. Reason: remove copyright material, see moderator comments