Summary: How to explode an instance of a block
Use RhinoScript's ExplodeBlockInstance method to explode an instance of a block into its geometric components. But, it is possible for a block to contain other blocks. These sub-blocks are known as nested blocks. The ExplodeBlockInstance method will not explode nested blocks. It is possible to write a script that uses recursion to do this for us.
The following sample script demonstrates how to explode all visible block instances into their geometric components. The script works on blocks that have nested blocks.
Sub SuperExplodeBlock Const rhInstanceObject = 4096 Dim arrBlocks, strBlock arrBlocks = Rhino.ObjectsByType(rhInstanceObject) If IsArray(arrBlocks) Then For Each strBlock In arrBlocks If Rhino.IsObjectSelectable(strBlock) Then DoInstanceExplosion strBlock End If Next End If End Sub Sub DoBlockExplosion(strBlock) Dim arrObjects, strObject If Rhino.IsBlockInstance(strBlock) Then arrObjects = Rhino.ExplodeBlockInstance(strBlock) If IsArray(arrObjects) Then For Each strObject In arrObjects DoBlockExplosion strObject '*RECURSE* Next End If End If End Sub