Rhinocommon access Nested Blocks


I am trying to do something and I am not sure what the optimal way is…I want to select a bunch of Rhino Objects (and some of them might be Blocks or nested Blocks), and search for a specific object (or a block) with a specific name.

Once I iterate through them:

foreach (RhinoObject obj in selectedObjs)

  1. I want to be able to check if the Object is a block (InstanceDefinition)
  2. Once I identify a block, in case it is a nested one (can I know immediatelly?), I want to recursively go down the rabbit hole and check the name of all blocks/objects at every level, including the objects in the lowest level.

So it is a sort of a thorough “SelName” function that goes inside the nested Blocks as well…

What would be the best way to do this?


Here are a couple of samples that demonstrate how to walk a instance reference or instance defintion:



Maybe these will give you some ideas.

– Dale