Rhinoscript to rhino common - bounding box and select


I have for long written codes in python for rhino using rhinoscriptsyntax but since I have now to deal with a large number of geometries to be processed I thought that it could improve the speed of the code by using rhino common syntax instead (which I understand would run much faster). Hope the question below is not too stupid!

I am trying to select objects (one set from layer and one from selection) get their bounding box and compare them.

My first problem is that I don’t know what is the equivalent of GetObjects and GetObjectsByLayer in rhino common. I tried Rhino.Input.RhinoGet.GetMultipleObjects() but doesn’t seem to work (requires all the inputs?)

The second is that even if I use rhinoscriptsyntax I cannot evaluate the bounding boxes by using Rhino.Geometry.BoundingBox(rs.coercegeometry(objs02[j])) as it is telling me that a Brep is returned while Ienumerable required.

Sample code below.

Any suggestion? In general where would you look if you have to translate a script from rhinoscriptsyntax to rhino library?

Many thanks in advance

import rhinoscriptsyntax as rs
import Rhino

objs01 = rs.ObjectsByLayer(“1”)
objs02 = rs.GetObjects()


for i in range(0,len(objs01)):
for j in range(0,len(objs02)):

    box1 = rs.BoundingBox(objs01[i])
    box2 = rs.BoundingBox(objs02[j])
    if box1 == box2:

Hi revink,

Not a specific answer to you question but rather a few links to guide you into RhinoCommon. This way you know how to see how methods like ObjectsByLayer use RhinoCommon

Also to format python code in a post use this wrapper:

code here

Translates to:

code here

The links:

Let us know if you have more questions.