Site Tools


This shows you the differences between two versions of the page.

Link to this comparison view

developer:scriptsamples:superexplodeblock [2015/09/14] (current)
Line 1: Line 1:
 +====== Exploding Block Instances ======
 +> **Developer:​** //​[[developer:​rhinoscript|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.
 +<code vb>
 + 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
 +{{tag>​Developer RhinoScript}}
developer/scriptsamples/superexplodeblock.txt ยท Last modified: 2015/09/14 (external edit)