TheSwamp
Code Red => VB(A) => Topic started by: TR on May 09, 2005, 05:36:47 PM
-
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
-
I regularly use both ... each has their purposes and as you have said.. I have not experienced any significant speed degradation
-
I guess I tend to use selection sets more often, but that's mainly because I'm after harvesting groups of like objects, although I have used t'other method once or twice.
My philosophy is.. if it works and doesn't throw a wobbly then it's ok.
-
I guess I tend to use selection sets more often, but that's mainly because I'm after harvesting groups of like objects, although I have used t'other method once or twice.
My philosophy is.. if it works and doesn't throw a wobbly then it's ok.