TheSwamp

Code Red => VB(A) => Topic started by: David Hall on October 15, 2007, 02:44:12 PM

Title: VP on layer
Post by: David Hall on October 15, 2007, 02:44:12 PM
Does anyone know how to manipulate a VP's layer thru code?  This does not work
Code: [Select]
      Dim objViewport As AcadViewport
      For Each objViewport In ThisDrawing.Viewports
      objViewport.Layer = "DEFPOINTS"
      Next objViewport
Title: Re: VP on layer
Post by: Guest on October 15, 2007, 03:01:44 PM
I've used the following code for something similar.... locking all viewports.
I added the 'layer = Defpoints' and it still works fine.

There's probably a better way than what I'm doing, but hey... if it ain't broke.


Code: [Select]
Public Sub x()
    Dim FilterType(0) As Integer
    Dim FilterData(0) As Variant
    Dim sset As AcadSelectionSet
    Dim objVP As AcadPViewport
    Dim x As Integer
   
    FilterType(0) = "0"
    FilterData(0) = "VIEWPORT"

    Set sset = vbdPowerSet("VPUpdate")
    sset.Select acSelectionSetAll, , , FilterType, FilterData
    For x = 0 To sset.Count - 1
        Set objVP = sset(x)
        objVP.Layer = "Defpoints"
        objVP.DisplayLocked = True
    Next x
End Sub

Private Function vbdPowerSet(strName As String) As AcadSelectionSet
    Dim objSelSet As AcadSelectionSet
    Dim objSelCol As AcadSelectionSets
   
    Set objSelCol = ThisDrawing.SelectionSets
    For Each objSelSet In objSelCol
        If objSelSet.Name = strName Then
            objSelSet.Delete
            Exit For
        End If
    Next
    Set objSelSet = ThisDrawing.SelectionSets.Add(strName)
    Set vbdPowerSet = objSelSet
End Function
Title: Re: VP on layer
Post by: David Hall on October 15, 2007, 03:04:04 PM
DUH, I am such an Idiot, I didn't use AcadPViewport

thanks