Hi all,
maybe I miss some theoretical information about selectionsets, but the autocad vba guide (and a search in this forum) cannot point me in the right direction...
EDIT: I should have read the "EffectiveName" autocad vba guide page better. It seems there's no way to select dynamic blocks using the block name other than selecting all the anonymous block references and looping through them. does .NET have a better approach to this? if yes, I really should consider switching to it!
I created (well, I copied from multiple sources) a function that uses selectionsets to look for objects:
Code:
Public Function SelectObjects(aDrawing As AcadDocument, ssObs As AcadSelectionSet, spObjectType As String, Optional spName As String = "*", Optional spLayer As String = "*", Optional spVisible As Integer = 0, Optional spSpace As Integer = 0) As Long
Dim FilterType(0 To 4) As Integer
Dim FilterData(0 To 4) As Variant
Dim sNumber As String
FilterType(0) = 0: FilterData(0) = spObjectType
FilterType(1) = 2: FilterData(1) = spName
FilterType(2) = 8: FilterData(2) = spLayer
FilterType(3) = 60: FilterData(3) = spVisible '0=visible, 1=invisible
FilterType(4) = 67: FilterData(4) = spSpace '0= modelspace, 1=paperspace
On Error Resume Next 'ignore errors if SSET doesn't exist
aDrawing.SelectionSets.Item("SSET").Delete
On Error GoTo SOLErrorHandler
Set ssObs = aDrawing.SelectionSets.Add("SSET")
ssObs.Select acSelectionSetAll, , , FilterType, FilterData
SelectObjects = ssObs.Count
Exit Function
SOLErrorHandler:
Err.Clear
SelectObjects = 0
End Function ' SelectObjects()
I need to select dynamic block references whose block name follows a pattern like "*_CLASS*_EDIT*" (using quickselect with that pattern correctly gives me what I want), but
Code:
SelectObjects(acadDoc, acadSelection, "INSERT", "*_CLASS*_EDIT*", "0", 0, 0)
gives me nothing (returns 0).
Code:
SelectObjects(acadDoc, acadSelection, "INSERT", "*_CLASS*_EDIT*,`*U*", "0", 0, 0)
instead, gives me all the unnamed block references (along with what I'm looking for), but it defeats the entire purpose of the selection set filter.
In any case I check for the effectivename of the block reference to make sure I'm handling the correct one, but since I have to run this code on ~1000 drawings, and there are at most 2 block references I need over about 30 block references found, I'd waste precious computing time (and work hours waiting for the macro to complete ).
How can I fix this?
Thanks for the attention!