McNeel Wiki
How To: Explode a Block Instance
edit · print · help · all topics
Main Pages

AccuRender

Bongo

Brazil r/s

Developer

Flamingo

Penguin

Rhino Blogs

Rhino

Rhino Labs

Search

Languages

Česky

Deutsch

English

Español

Français

Italiano

Polish

日本語

한국어

中文(繁體)

中文(简体)

 
.
TitleHow To: Explode a Block Instance
DeveloperRhinoScript
SummaryHow to explode an instance of a block.

RhinoScripts 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.

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
rename · changes · history · subscriptions · lost and found · references · file upload