Block Count

I am using rhinocommon to list my blocks
I can get the name of the blocks with doc.InstanceDefinitions(i).Name, and i want to see the numbers of each block items seperately.
How can i achieve this?
M6 bolts(block instance) : 12 pcs
M8 bolts(block instance) : 6 pcs

Hi Serdem

This seems to work

import Rhino

def main():

get references and store in dictionary

robs = list( Rhino.RhinoDoc.ActiveDoc.Objects.FindByObjectType(
Rhino.DocObjects.ObjectType.InstanceReference ) )
blocks = dict( )
for rob in robs:
obref = Rhino.DocObjects.ObjRef( rob )
refer = obref.Geometry()
definid = refer.ParentIdefId
if definid in blocks:
count = blocks[ definid ]
blocks[ definid ] = count + 1
blocks[ definid ] = 1

get definitions and read instance count from dictionary

table = Rhino.RhinoDoc.ActiveDoc.InstanceDefinitions
for defin in table:
name = defin.Name
guid = defin.Id
if guid in blocks:
count = blocks[ guid ]
count = 0
print ‘%s(block instance) : %2d pieces’ % ( name, count )


HTH, cheers


It looks I’m not able to insert indented code … here is the file: (824 Bytes)

1 Like

Here is a RhinoScript that does something similar:


– Dale

Hi all,

has anyone a c# or vb version of that or something similiar? I am not able to fully understand the python.