PVport not created

Discussion in 'AutoCAD' started by Marie Desaulniers, Jun 11, 2004.

  1. I'm trying to create a viewport in a specific layout and it doesn't work. I read a lot of post but I can't find what is wrong with my code. Someone can help me ?

    Dim objVp As AcadPViewport
    Dim ptCenter(0 To 2) As Variant
    Dim dblWidth As Double
    Dim dblHeight As Double

    ThisDrawing.ActiveLayout = ThisDrawing.Layouts("General")
    ptCenter(0) = 106.75
    ptCenter(1) = 99.25
    ptCenter(2) = 0#
    dblWidth = 198.85
    dblHeight = 177#
    set objVp = ThisDrawing.PaperSpace.AddPViewport(ptCenter, dblWidth, dblHeight)
    With objVp
    Display (True)
    ViewportOn = True
    End With

    ThisDrawing.Regen acAllViewports

    Thanks,

    Marie
     
    Marie Desaulniers, Jun 11, 2004
    #1
  2. Marie Desaulniers

    Hal Perison Guest

    Marie,

    The problem lies in the declaration of the variable ptCenter.

    You have declared it as follows:
    Dim ptCenter(0 To 2) As Variant
    when in fact it should be:
    Dim ptCenter As Variant

    and then:
    ReDim ptCenter(0 To 2) As Double

    This will put the variable in the form that VBA is looking for.

    or you can simply declare ptCenter as a double instead of a variant and this should work as well.

    Hal
     
    Hal Perison, Jun 11, 2004
    #2
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.