How to add a PAPERSPACE VIEW to the view collection?

Discussion in 'AutoCAD' started by Erik Droog, Sep 23, 2004.

  1. Erik Droog

    Erik Droog Guest

    I want to create a view of a part of an layout (not the modelspace layout!)

    When I use the thisdrawing.views.add method it adds a modelspace view to the
    view collection.

    How do I add a LAYOUT view to the view collection?

    TIA

    Erik
     
    Erik Droog, Sep 23, 2004
    #1
  2. Erik Droog

    VBA Guest

    You will need to be in floating modelspace in order for this to work.
     
    VBA, Sep 24, 2004
    #2
  3. Huh? No, he wants to add a viewport to the layout.

    Your terminology is incorrect, Erik. You need to use the PViewPort object
    to add the viewport to the layout. Views are only for model space. Here are
    the basics but make sure you have switched to the layout you want and sset
    ModelSpace = False

    Dim oPVport As AcadPViewport 'viewport
    Dim dVportPts(2) As Double 'viewport center point
    Dim dVportHgt As Double 'height of pviewport
    Dim dVportWid As Double 'width of pviewport
    'define the pspace viewport
    dVportPts(0) = 14.7
    dVportPts(1) = 10.2
    dVportPts(2) = 0
    dVportHgt = 7.5
    dVportWid = 11
    'create the pspace viewport
    oPVport = ThisDrawing.PaperSpace.AddPViewport(dVportPts, _
    dVportWid, dVportHgt)
    'make sure pspace viewport is visible
    oPVport.Display = True
    'set the viewport to show entire view
    oPVport.StandardScale = AcViewportScale.acVpScaleToFit
    'turn off pspace viewport boundary lines
    oPVport.Visible = False
    'lock the viewport
    oPVport.DisplayLocked = True

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 25, 2004
    #3
  4. Erik Droog

    Erik Droog Guest

    Thanks for your relpy

    I'm afraid you don't understand what I want to do:

    I want to add a VIEW to a paperspace layout. A view, the one you are using
    for plotting. Not a viewport.
    Somehow this isn't allowed with "ThisDrawing.Views.Add". That's only for
    views in modelspace.
     
    Erik Droog, Oct 5, 2004
    #4
  5. Ok, now I'm on the same page. If you have 2005, then there is an
    unpublished property of the view object -- .LayoutID or you can dim your
    view object as an IAcadView2 instead of just AcadView. The code below will
    do it. I *believe* this was introduced in 2005, so in any lower version,
    you're outta luck.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...


    Sub AddPViewPort()
    Dim oView As AcadView
    Dim oDwg As AcadDocument
    Dim v1Pt As Variant
    Dim v2Pt As Variant
    Dim dCpt(1) As Double
    Dim dHgt As Double
    Dim dWid As Double
    Set oDwg = ThisDrawing
    With oDwg
    .ActiveSpace = acPaperSpace
    .MSpace = False
    v1Pt = .Utility.GetPoint(, "Select first corner of View: ")
    v2Pt = .Utility.GetCorner(v1Pt, "Select opposite corner of View: ")
    End With
    dHgt = IIf(v2Pt(1) > v1Pt(1), v2Pt(1) - v1Pt(1), v1Pt(1) - v2Pt(1))
    dWid = IIf(v2Pt(0) > v1Pt(0), v2Pt(0) - v1Pt(0), v1Pt(0) - v2Pt(0))
    dCpt(0) = (v2Pt(0) + v1Pt(0)) / 2
    dCpt(1) = (v2Pt(1) + v1Pt(1)) / 2
    Set oView = oDwg.Views.Add("myView")
    With oView
    .Center = dCpt
    .Height = dHgt
    .Width = dWid
    .LayoutId = oDwg.ActiveLayout.ObjectID
    End With
    If Not oView Is Nothing Then Set oView = Nothing
    If Not oDwg Is Nothing Then Set oDwg = Nothing
    End Sub
     
    Mike Tuersley, Oct 6, 2004
    #5
  6. Erik Droog

    Erik Droog Guest

    Hi Mike.

    I don't have 2005 installed yet although we do have bought it...
    This might be the right time to change to 2005.

    Indeed the code isn't working in 2004.

    Thanx
     
    Erik Droog, Oct 11, 2004
    #6
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.