Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: View From Viewport

  1. #11
    Certifiable AUGI Addict tedg's Avatar
    Join Date
    2005-06
    Location
    in the upper right corner
    Posts
    2,633
    0 Did you find this post helpful? Yes

    Default Re: View From Viewport

    Quote Originally Posted by tedg
    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
    I understand, I've had that routine so long I can't remember where I got it. I totally respect that whole copyright infringement thing. I'm still a bit "green" at this information sharing thing.

    I will only post files I've created or have the permission of the author.

    What do you do if you don't know who the orignial author is of a particular routine?
    If there's no name or anything in the file, is it free-range?

    Ted

  2. #12
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2002-12
    Location
    Brandon, Florida
    Posts
    687
    0 Did you find this post helpful? Yes

    Default Re: View From Viewport

    When I save a routine from a web site I paste the URL in the lisp file for future reference.
    You may want to link back to the place you found it.
    Perhaps you can post the link & not the routine so others may find it as well.

  3. #13
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    0 Did you find this post helpful? Yes

    Default Re: View From Viewport

    Incase anyone is still looking at this thread, here is the updated version of my routine that will wok when you have rotated the ucs. I'm not sure about with twists, as I don't use them, so I don't really know how to test them.

    Have fun.
    Code:
    (defun c:VG ( / ActDoc Vpss VpEnt Vport Ent EntData EntType PtList VpType VpRad MjrAx RadRto VpCntPs VpCnt VpSc MdSpace
                   NewPtList VpModel cnt)
    ; Will draw in model space, where the viewport is showing.  If you are in a viewport, then it will draw that one,
    ;  if you are not, then it will let you select the viewport.
    ; Sub's - 'list->variant
    
    (setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
    (vla-EndUndoMark ActDoc)
    (vla-StartUndoMark ActDoc)
    (setq MSpace (vla-get-MSpace ActDoc))
    (if
     (and
      (/= (strcase (getvar "ctab")) "MODEL")
      (if (equal (setq VpId (getvar "cvport")) 1)
       (Setq vpss (ssget '((0 . "VIEWPORT"))))
       (setq Vpss (ssget "x" (list '(0 . "VIEWPORT") (cons 69 VpId))))
      )
      (setq cnt -1)
     )
     (while (setq VpEnt (ssname Vpss (setq cnt (1+ cnt))))
      (setq PtList nil)
      (setq NewPtList nil)
      (setq VpType nil)
      (setq Vport (vlax-ename->vla-object VpEnt))
      (if (setq Ent (cdr (assoc 340 (entget VpEnt))))
       (cond
        ((= (setq EntType (cdr (assoc 0 (setq EntData (entget Ent))))) "LWPOLYLINE")
         (setq tmpList (vlax-get (vlax-ename->vla-object Ent) 'Coordinates))
         (setq cnt 0)
         (while (< cnt (length tmpList))
          (setq PtList (cons (list (nth cnt tmpList) (nth (1+ cnt) tmpList) 0.0) PtList))
          (setq cnt (+ 2 cnt))
         )
         (setq VpType "Poly")
        )
        ((= EntType "CIRCLE")
         (setq VpRad (cdr (assoc 40 EntData)))
         (setq VpType "Circle")
        )
        ((= EntType "ELLIPSE")
         (setq MjrAx (cdr (assoc 11 EntData)))
         (setq RadRto (cdr (assoc 40 EntData)))
         (setq VpType "Ellipse")
        )
       )
       (progn
        (vla-GetBoundingBox Vport 'MnPt 'MxPt)
        (setq MnPt (safearray-value MnPt))
        (setq MxPt (safearray-value MxPt))
        (setq temp1 (list (car MxPt) (cadr MnPt) (caddr MnPt)))
        (setq temp2 (list (car MnPt) (cadr MxPt) (caddr MnPt)))
        (setq PtList (list MnPt temp1 MxPt temp2))
        (setq VpId (cdr (assoc 69 (entget VpEnt))))
       )
      )
      (setq VpCntPs (vlax-get Vport 'Center))
      (if (vl-catch-all-apply 'vla-put-MSpace (list ActDoc :vlax-true))
       (progn
        (vla-ZoomAll (vlax-get-Acad-Object))
        (vla-put-ModelSpace ActDoc ':vlax-true)
       )
      )
      (vla-SetVariable ActDoc "cvport" VpId)
      (setq VpCnt (getvar "viewctr"))
      (setq VpCntPs (trans VpCntPs 0 2))
      (setq PtList (mapcar '(lambda (x) (trans x 0 2)) PtList))
      (setq VpSc (vla-get-CustomScale Vport))
      (setq MdSpace (vla-get-ModelSpace ActDoc))
      (if PtList
       (progn
        (foreach item PtList
         (foreach item2 (list (car item) (cadr item))
          (setq NewPtList (cons item2 NewPtList))
         )
        )
        (setq PtList (list->variant (reverse NewPtList) vlax-vbDouble))
       )
      )
      (cond
       ((= VpType "Poly")
        (setq VpModel (vla-AddLightweightPolyline MdSpace PtList))
        (if (= (vla-get-Closed VpModel) ':vlax-false)
         (vla-put-Closed VpModel ':vlax-true)
        )
        (vla-Move VpModel (vlax-3d-point VpCntPs) (vlax-3d-point (trans VpCnt 1 0)))
       )
       ((= VpType "Circle")
        (setq VpModel (vla-AddCircle MdSpace (vlax-3d-point (trans VpCnt 1 0)) VpRad))
       )
       ((= VpType "Ellipse")
        (setq VpModel (vlax-invoke MdSpace 'AddEllipse (trans VpCnt 1 0) MjrAx RadRto))
       )
       (
        (setq VpModel (vla-AddLightweightPolyline MdSpace PtList))
        (if (= (vla-get-Closed VpModel) ':vlax-false)
         (vla-put-Closed VpModel ':vlax-true)
        )
        (vla-Move VpModel (vlax-3d-point VpCntPs) (vlax-3d-point (trans VpCnt 1 0)))
       )
      )
      (vla-ScaleEntity VpModel (vlax-3d-point (trans VpCnt 1 0)) (/ 1.0 VpSc))
      (vl-catch-all-apply 'vla-put-Layer (list VpModel "Defpoints"))
     )
     (prompt "\n No Viewport active.")
    )
    (vla-put-MSpace ActDoc MSpace)
    (vla-EndUndoMark ActDoc)
    (princ)
    )
    ;-------------------------------------------------------------------------------------
    (defun list->variant (lst vartype)
    ; By Frank Oquendo
    
    (vlax-make-variant
     (vlax-safearray-fill
      (vlax-make-safearray vartype (cons 0 (1- (length lst))))
      lst
      )
     )
    )

  4. #14
    100 Club jimmy.bergmark's Avatar
    Join Date
    2000-11
    Location
    Sweden
    Posts
    126
    0 Did you find this post helpful? Yes

    Default Re: View From Viewport

    http://jtbworld.blogspot.com/2006/04...-based-on.html

    Thanks goes to Tom Beauford that added support for twisted views
    Updated download available here:
    http://www.jtbworld.com/lisp/vp-outline.htm
    Jimmy Bergmark
    JTB World - Software development and consulting
    Owner/Developer
    Homepage: http://www.jtbworld.com
    Blog: http://blog.jtbworld.com
    ACA (ADT) Certified Expert

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Rotating a Viewport Rotates the View in the Viewport
    By acadwishlist 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. Is there a way to view the scale of a particular viewport?
    By voineavlad in forum AutoCAD LT - General
    Replies: 3
    Last Post: 2006-09-13, 12:23 PM
  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
  •