Selectionset for dynamic block

Selectionset for dynamic block

Anonymous
Not applicable
849 Views
2 Replies
Message 1 of 3

Selectionset for dynamic block

Anonymous
Not applicable
I try to create a selectionset for my dynamic block "Myblock".I used group code to select all "Myblock" into selectionset.the group code is:
groupcode(0)=2: blockname(0)="Myblock"
selectionset acselectionsetall,,,groupcode,blockname
the problem is there is nothing in the selectionset, no matter I use dynamic block's effectivename or just dynamic block's name.I can't get anything in my selectionset.Is the filter wrong or...?
Thank in advance.

Starline
0 Likes
850 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
This has been discussed several times recently. A search will reveal some
approaches you can take.

At issue is that once you change a DBlock from its default display, it
becomes an anonymous block who's EffectiveName is the original block Name.

--
R. Robert Bell


wrote in message news:[email protected]...
I try to create a selectionset for my dynamic block "Myblock".I used group
code to select all "Myblock" into selectionset.the group code is:
groupcode(0)=2: blockname(0)="Myblock"
selectionset acselectionsetall,,,groupcode,blockname
the problem is there is nothing in the selectionset, no matter I use dynamic
block's effectivename or just dynamic block's name.I can't get anything in
my selectionset.Is the filter wrong or...?
Thank in advance.

Starline
0 Likes
Message 3 of 3

Anonymous
Not applicable
Hey Starline,
I have recovered from the same problem which you are going through. this code will help you. Paste tis code in a new module and test it. It will hel p you. I also psted the same problem. 🙂
Thanks
Anshu
****************************
Private Sub funkyrefs()

Dim oBRef As IAcadBlockReference2
Dim oBlock As IAcadBlock3
Dim oBlocks As AcadBlocks
Dim strDynamicBlock As String
Dim strBRefName As String
Dim FilterType() As Integer
Dim FilterData() As Variant
Dim ss As AcadSelectionSet
Dim i As Integer
For Each ss In ThisDrawing.SelectionSets
If ss.Name = "SS" Then
ss.Delete
Exit For
End If
Next
ReDim FilterType(0), FilterData(0)
FilterType(0) = 0: FilterData(0) = "Insert"
Set ss = ThisDrawing.SelectionSets.Add("SS")
ss.Select 5, , , FilterType:=FilterType, FilterData:=FilterData

For i = 0 To ss.Count - 1
If ss(i).IsDynamicBlock Then
Set oBRef = ss(i)
strBRefName = oBRef.Name
If Left(strBRefName, 1) = "*" Then
strBRefName = "`" + strBRefName
End If
Debug.Print oBRef.EffectiveName, oBRef.Name
If strDynamicBlock = "" Then
strDynamicBlock = strBRefName
Else
strDynamicBlock = strDynamicBlock + "," + strBRefName
End If
End If
Next
ss.Delete
Debug.Print strDynamicBlock
ReDim FilterType(1), FilterData(1)
FilterType(0) = 0: FilterData(0) = "Insert"
FilterType(1) = 2: FilterData(1) = strDynamicBlock

Set ss = ThisDrawing.SelectionSets.Add("SS")
ss.Select 5, , , FilterType:=FilterType, FilterData:=FilterData
For i = 0 To ss.Count - 1
Set oBRef = ss(i)
Dim dynProp As AcadDynamicBlockReferenceProperty
Set dynProp = oBRef.GetDynamicBlockProperties(0)

Debug.Print oBRef.EffectiveName, oBRef.Name
Next

ss.Delete

End Sub
0 Likes