PViewport Modelspace Coordinates

Discussion in 'AutoCAD' started by KevinV, Jul 4, 2003.

  1. KevinV

    KevinV Guest

    Is there a way to get the modelspace coordinates of the region displayed within a viewport? Now that everyone has fully embraced the multiple layout functionality from 2000, I would like to be able to output all of the viewport extents from all of the layout tabs of a drawing as polyline rectangles in modelspace.

    With TwistAngle, Height, Width, and Scale properties, I can get the size and orientation of the box, but how do I figure out where to put it? The only coordinate properties I can find all relate to Paperspace.

    Any help on this would be much appreciated!
     
    KevinV, Jul 4, 2003
    #1
  2. KevinV

    Jürg Menzi Guest

    Kevin

    try something like this:

    Function DrawVportFrame(VptObj As AcadPViewport)

    Dim PliObj As AcadLWPolyline
    Dim LlfPnt As Variant
    Dim UrgPnt As Variant
    Dim VptCen As Variant
    Dim VptLlf(0 To 2) As Double
    Dim VptUrg(0 To 2) As Double
    Dim VtxLst(0 To 7) As Double
    Dim XofSet As Double
    Dim YofSet As Double

    With VptObj
    VptCen = .Center
    XofSet = .Width / 2
    YofSet = .Height / 2
    VptLlf(0) = CDbl(VptCen(0)) - XofSet
    VptLlf(1) = CDbl(VptCen(1)) - YofSet
    VptLlf(2) = 0#
    VptUrg(0) = CDbl(VptCen(0)) + XofSet
    VptUrg(1) = CDbl(VptCen(1)) + YofSet
    VptUrg(2) = 0#
    LlfPnt = CVar(VptLlf)
    UrgPnt = CVar(VptUrg)
    With ThisDrawing
    With .Utility
    LlfPnt = .TranslateCoordinates(LlfPnt, acPaperSpaceDCS, acDisplayDCS,
    False)
    UrgPnt = .TranslateCoordinates(UrgPnt, acPaperSpaceDCS, acDisplayDCS,
    False)
    End With
    VtxLst(0) = CDbl(LlfPnt(0)): VtxLst(1) = CDbl(LlfPnt(1))
    VtxLst(2) = CDbl(UrgPnt(0)): VtxLst(3) = CDbl(LlfPnt(1))
    VtxLst(4) = CDbl(UrgPnt(0)): VtxLst(5) = CDbl(UrgPnt(1))
    VtxLst(6) = CDbl(LlfPnt(0)): VtxLst(7) = CDbl(UrgPnt(1))
    Set PliObj = .ModelSpace.AddLightWeightPolyline(VtxLst)
    End With
    With PliObj
    .Closed = True
    .Color = acRed
    .Update
    End With
    End With
    End Function

    Cheers
     
    Jürg Menzi, Jul 5, 2003
    #2
  3. KevinV

    KevinV Guest

    Jeff, Jurg,

    Thanks! I knew there had to be a way. TranslateCoordinates does exactly what I need

    Kevin
     
    KevinV, Jul 7, 2003
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.