Which do you prefer to use? I have used both methods and I find the For Each Method a lot easier to code and understand. I also haven't noticed that much of a speed difference between the two. Has anyone else?
Note: The code below is just a modified version of some stuff I had. It is for example only and it wasn't tested to see if it works.
For Each:
Public Sub Test()
Dim ae As AcadEntity
For Each ae In ThisDrawing.ModelSpace
If TypeOf ae Is AcadRasterImage Then
MsgBox (ae.Name)
End If
Next
Selection Set:
Public Sub Test2()
Dim SelSet As AcadSelectionSet
Dim FilterType(0 To 0) As Integer
Dim FilterData(0 To 0) As Variant
Dim AT As AcadAttribute
FilterType(0) = 0
FilterData(0) = "ATTDEF"
On Error GoTo Exit_Error
ThisDrawing.SelectionSets.Add "SelSet"
Set SelSet = ThisDrawing.SelectionSets("SelSet")
SelSet.Clear
SelSet.Select acSelectionSetAll, , , FilterType, FilterData
If SelSet.Count <> 0 Then
For Each AT In SelSet
MsgBox (AT.Name)
Next
End If
SelSet.Clear
Exit_Error:
Select Case Err.Number
Case -2145386494 'not applicable
Resume Next
Case Else
SelSet.Delete
Set SelSet = Nothing
Set AT = Nothing
Set TXT = Nothing
End Select
End Sub