Working with an exploded block

Working with an exploded block

Anonymous
Not applicable
1,220 Views
3 Replies
Message 1 of 4

Working with an exploded block

Anonymous
Not applicable

I am working with a block composed of two smaller blocks, both smaller blocks have their own dynamic properties. I would like to explode my block and then edit the dynamic attributes of one of the resulting blocks, but am running into some issues. I am aware that you can loop through the resulting objects that result from an exploded block and make some property changes. But I am unable to turn one of the resulting objects into an objectblockreference so that I can change one of the dynamic properties. Has anyone ever done this before, or have any ideas that could help me move forward?

0 Likes
Accepted solutions (1)
1,221 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

To clarify, at the very least, I am trying to set one of the resulting blocks as an acadblockreference after the parent block has been exploded.

0 Likes
Message 3 of 4

norman.yuan
Mentor
Mentor
Accepted solution

What does it mean by saying "... I am unable to turn one of the resulting objects into an objectblockreference..."? It'd be better if showed your relevant code. 

 

AcadBlockreference returns a Variant value, which is an array of AcadEntity, wihch are the constituent entities in the block definition.  I guess you need to do is the loop through the result array and test each one to see if it is an AcadBlockReference. Following sample code shows this approach:

Public Sub TestExplode()

    Dim ent As AcadEntity
    Dim pt As Variant
    Dim blk As AcadBlockReference
    Dim ents As Variant
    Dim i As Integer
    
    ThisDrawing.Utility.GetEntity ent, pt, vbCr & "Select block:"
    If TypeOf ent Is AcadBlockReference Then
        Set blk = ent
        ents = blk.Explode
        If UBound(ents) >= 0 Then
            For i = 0 To UBound(ents)
                If TypeOf ents(i) Is AcadBlockReference Then
                    Set blk = ents(i)
                    MsgBox "Entity " & (i + 1) & " from exploded block is block """ & blk.EffectiveName & """"
                End If
            Next
        End If
    End If
    
End Sub

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 4

zhenliang.fu
Contributor
Contributor

The sample code is not applicable for external block reference (xref), select the xref block return the error.

Run-time error.PNG

0 Likes