Selection Set Error

Discussion in 'AutoCAD' started by Tim Riley, Jul 10, 2003.

  1. Tim Riley

    Tim Riley Guest

    I'm using the following code in my acad.dvb!thisdrawing module. The purpose
    is to check the drawing for attribute definitions, change them to a new
    layer, and prompt you that there are definitions. I am getting reports from
    users that they are receiving run-time errors when they exit a drawing and I
    don't know why. Anyone have a clue?

    Tim Riley

    ********code****************************************************************
    *****

    Option Explicit
    Public Sub AcadStartUp()

    Dim SelSet As AcadSelectionSet
    Dim AT As AcadAttribute
    Dim FilterType(0 To 0) As Integer
    Dim FilterData(0 To 0) As Variant
    Dim File As String
    Dim FixLay As AcadLayer
    Dim SingleLay As AcadLayer
    Dim TotLay As AcadLayers

    FilterType(0) = 0
    FilterData(0) = "ATTDEF"

    On Error Resume Next
    ThisDrawing.SelectionSets.Add "SelSet"
    Set SelSet = ThisDrawing.SelectionSets("SelSet")
    SelSet.Clear
    On Error GoTo 0

    SelSet.Select acSelectionSetAll, , , FilterType, FilterData

    If SelSet.Count <> 0 Then
    MsgBox "You Have " & SelSet.Count & " Attribute Definition(s) in " &
    ThisDrawing.Name & ". Please Change Them To Text."
    'Create a new layer
    Set FixLay = ThisDrawing.Layers.Add("Fix_Attributes")
    FixLay.Color = acRed
    Else:
    Exit Sub
    End If

    For Each AT In SelSet
    AT.Color = acByLayer
    AT.Layer = "Fix_Attributes"
    Next

    End Sub

    Private Sub AcadDocument_Activate()
    Call AcadStartUp
    End Sub
     
    Tim Riley, Jul 10, 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.