Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: View From Viewport

  1. #1
    I could stop if I wanted to
    Join Date
    2004-11
    Location
    Somewhere close to hell
    Posts
    228
    Login to Give a bone
    0

    Lightbulb View From Viewport

    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

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: View From Viewport

    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

  3. #3
    I could stop if I wanted to
    Join Date
    2004-11
    Location
    Somewhere close to hell
    Posts
    228
    Login to Give a bone
    0

    Default Re: View From Viewport

    Tom,
    Thanks for the info, this gives me a place to start.
    Rob

  4. #4
    Member
    Join Date
    2004-11
    Posts
    3
    Login to Give a bone
    0

    Default Re: View From Viewport

    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?

  5. #5
    I could stop if I wanted to
    Join Date
    2004-11
    Location
    Somewhere close to hell
    Posts
    228
    Login to Give a bone
    0

    Default Re: View From Viewport

    Quote Originally Posted by tom.wilshusen
    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,
    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

  6. #6
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: View From Viewport

    Try this thread.

  7. #7
    Member
    Join Date
    2004-11
    Posts
    3
    Login to Give a bone
    0

    Default Re: View From Viewport

    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.

  8. #8
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: View From Viewport

    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.

  9. #9
    I could stop if I wanted to JASONM30395's Avatar
    Join Date
    2002-04
    Location
    Halifax NS Canada
    Posts
    397
    Login to Give a bone
    0

    Default Re: View From Viewport

    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!

  10. #10
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    3,507
    Login to Give a bone
    0

    Thumbs up Re: View From Viewport

    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

Page 1 of 2 12 LastLast

Similar Threads

  1. Rotating a Viewport Rotates the View in the Viewport
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 3
    Last Post: 2012-07-19, 11:36 AM
  2. Replies: 0
    Last Post: 2012-02-24, 05:48 PM
  3. View List - Viewport
    By Mactn113 in forum Revit Architecture - General
    Replies: 0
    Last Post: 2009-04-20, 04:26 PM
  4. Rotate View in Viewport
    By drafting1 in forum AutoCAD General
    Replies: 8
    Last Post: 2006-05-08, 11:43 AM
  5. New Viewport Not Saving Last View
    By CADdancer in forum AutoLISP
    Replies: 3
    Last Post: 2005-03-20, 08:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •