Hi,
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?
ie:
M6 bolts(block instance) : 12 pcs
M8 bolts(block instance) : 6 pcs
Thanks
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
else:
blocks[ definid ] = 1get 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 ]
else:
count = 0
print ‘%s(block instance) : %2d pieces’ % ( name, count )
main()
HTH, cheers
EDIT:
It looks I’m not able to insert indented code … here is the file:
blockinstancelist.py (824 Bytes)
Hi all,
has anyone a c# or vb version of that or something similiar? I am not able to fully understand the python.
Regards!