Site Tools


Exploding Block Instances

Developer: RhinoScript
Summary: How to explode an instance of a block.

Overview

RhinoScript's ExplodeBlockInstance method can be used 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. But, it is possible to write a script that uses recursion to do this for us.

Example

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


developer/scriptsamples/superexplodeblock.txt · Last modified: 2015/09/14 (external edit)