setting current pviewport

Discussion in 'AutoCAD' started by lorier, Aug 23, 2003.

  1. lorier

    lorier Guest

    Hi,
    This is connected to a simple form consisting of an ok & cancel button and a listbox of layouts. I'm trying to be able to select layouts from the listbox and freeze the last layer created in all pviewports of the layouts selected. It seems to almost work, but I get an 'error setting current viewport' that I've been having trouble figuring out. Any ideas? thanks.

    ________________________
    Private Sub ok_Click()
    Dim i As Integer, x As Integer, y As Integer
    For i = 0 To ThisDrawing.Layouts.count - 1
        If LayoutListBox.Selected(i) = True Then
        ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item(i)
        Dim mypViewport As AcadPViewport
        Dim myObj As AcadObject
        Dim pvCount As Integer
        ThisDrawing.ActiveSpace = acPaperSpace



    For x = 0 To ThisDrawing.PaperSpace.count - 1
            Set myObj = ThisDrawing.PaperSpace.Item(x)
            If myObj.EntityName = "AcDbViewport" Then
                Set mypViewport = ThisDrawing.PaperSpace.Item(x)
                mypViewport.Display (True)
                ThisDrawing.mspace = True
                ThisDrawing.ActivePViewport = mypViewport '?
                ThisDrawing.SendCommand "VPLAYER" & vbCr & "F" & vbCr & ThisDrawing.LAYERS.Item(ThisDrawing.LAYERS.count - 1).Name & vbCr & vbCr & vbCr
                ThisDrawing.mspace = False
           End If
        Next x
    End If
    Next i
    End
    End Sub

    Private Sub UserForm_Initialize()
    LayoutForm.Caption = "VPLayer Freeze For Layouts - For Layer: " & ThisDrawing.LAYERS.Item(ThisDrawing.LAYERS.count - 1).Name
    Dim x As Integer

    For x = 0 To ThisDrawing.Layouts.count - 1
        LayoutListBox.AddItem ThisDrawing.Layouts.Item(x).Name
    Next x
    End Sub
    Private Sub cancelbutton_Click()
    End
    End Sub
    _________________
     
    lorier, Aug 23, 2003
    #1
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.