Sorry that I can't provide a simple fix but the following might work.
1. Create a selection set of all blocks in the drawing:
2. Use the like operator to move blocks you want from one selection set to the other
[code]
Dim BlockSet As AcadSelectionSet ' The working set of blocks
Dim SSet As AcadSelectionSet ' The set of all blocks
Dim SetName As String ' The selection set name
Dim BlockSetName As String ' The custom block list selection set name
Dim SSFilterType(0) As Integer
Dim SSFilterData(0) As Variant
Dim oCurBlock As AcadBlockReference
Dim strFilter As String ' The filter for block name
Dim strBlockName As String
SetName = "AllBlockFilterSet"
BlockSetName = "CustBlockSet"
On Error Resume Next ' Set up error Checking
Err.Clear
Set SSet = GetSelectionSet(SetName) ' Get Selection Set custom routine
If Err <> 0 Then
Err.Raise
End If
On Error GoTo 0
SSet.Clear ' Empty the Set
SSFilterType(0) = 0 ' Select Entity Name
SSFilterData(0) = "INSERT" ' Select only Inserted Drawings
SSet.Select acSelectionSetAll, , , SSFilterType, SSFilterData ' Get a set of all blocks
On Error Resume Next ' Set up error Checking
Err.Clear
Set BlockSet = GetSelectionSet(BlockSetName) ' Get Selection Set custom routine
If Err <> 0 Then
Err.Raise
End If
On Error GoTo 0
BlockSet.Clear ' Empty the Set
strFilter = "MyCustBlock*" ' Get filter
For Each oCurBlock In SSet
If oCurBlock.IsDynamicBlock Then strBlockName = oCurBlock.EffectiveName _
Else strBlockName = oCurBlock.Name ' Get name of block
If strBlockName Like strFilter Then ' This block name matches the filter
BlockSet.AddItems oCurBlock ' Add block to set
End If
Next oCurBlock
[/code]
You can now use the BlockSet selection set in the rest of your code.
3. Helper routines
[code]
Public Function GetSelectionSet(SSetName As String) As AcadSelectionSet
' Funciton to either get or create a selection set with a name of SSetName
' Note that in code this selection set should be deleted when no longer needed
' so we don't exceed the 128 set limit
Dim l_SSet As AcadSelectionSet
Dim SSFound As Boolean
If Application.Documents.Count = 0 Then ' There are no open documents return an error
Err.Raise Number:=vbObjectError + 1, Source:="MiscUtils.GetSelectionSet", _
Description:="No Open Document"
End If
If ThisDrawing.SelectionSets.Count >= 128 Then ' There are more than 128 selection sets
return error
Err.Raise Number:=vbObjectError + 3, Source:="MiscUtils.GetSelectionSet", _
Description:="Can not Create Selection Set 128 Already Exist"
End If
SSFound = False ' Start with no Selection Set Found
For Each l_SSet In ThisDrawing.SelectionSets ' Parse Collection
If l_SSet.Name = SSetName Then ' Found a hit
SSFound = True ' Tell the rest of the program about it
Exit For ' Stop Parsing we found what we want
End If
Next l_SSet
If Not SSFound Then ' There is no selection set we want
Set l_SSet = ThisDrawing.SelectionSets.Add(SSetName) ' So Make it
SSFound = True
End If
Set GetSelectionSet = l_SSet ' Return it to the user
End Function
[/code]
Dim BlockSet As AcadSelectionSet ' The working set of blocks
Dim SSet As AcadSelectionSet ' The set of all blocks
Dim SetName As String ' The selection set name
Dim BlockSetName As String ' The custom block list selection set name
Dim SSFilterType(0) As Integer
Dim SSFilterData(0) As Variant
Dim oCurBlock As AcadBlockReference
Dim strFilter As String ' The filter for block name
Dim strBlockName As String
SetName = "AllBlockFilterSet"
BlockSetName = "CustBlockSet"
On Error Resume Next ' Set up error Checking
Err.Clear
Set SSet = GetSelectionSet(SetName) ' Get Selection Set custom routine
If Err <> 0 Then
Err.Raise
End If
On Error GoTo 0
SSet.Clear ' Empty the Set
SSFilterType(0) = 0 ' Select Entity Name
SSFilterData(0) = "INSERT" ' Select only Inserted Drawings
SSet.Select acSelectionSetAll, , , SSFilterType, SSFilterData ' Get a set of all blocks
On Error Resume Next ' Set up error Checking
Err.Clear
Set BlockSet = GetSelectionSet(BlockSetName) ' Get Selection Set custom routine
If Err <> 0 Then
Err.Raise
End If
On Error GoTo 0
BlockSet.Clear ' Empty the Set
strFilter = "MyCustBlock*" ' Get filter
For Each oCurBlock In SSet
If oCurBlock.IsDynamicBlock Then strBlockName = oCurBlock.EffectiveName _
Else strBlockName = oCurBlock.Name ' Get name of block
If strBlockName Like strFilter Then ' This block name matches the filter
BlockSet.AddItems oCurBlock ' Add block to set
End If
Next oCurBlock
On Mon, 30 Oct 2006 23:41:07 +0000, Mark Johnston <> wrote:
>This is an AutoCAD 2007 issue.
>I have upgraded (?) some blocks from standard blocks to dynamic blocks and now I find that some of my code will not find the blocks by name because dynamic blocks are assigned anonymous names. (*U???)
>There is a new blockreference property, .EffectiveName, that I can use to build a selection set but I would prefer for users to see selections filtered during the selection and not after. Besides, I have other functions that rely on filtering on block name and I don't want to re-write them.
>
>Is there a way to build a selection set filter that will look for DXF subclass markers?
>
>For example:
>0 = "INSERT"
>2 = "s_elev*"
>1001 = "AcDbDynamicBlockTrueName"
>1000 = "s_elev*"
>
>Or is there another way?