Selecting Geometrically Similar Objects

I am looking for a way to select geometrically similar objects, i.e. one command to select all 0.25" circles in the drawing. Being fully aware that this is a tricky problem to do efficiently, I was surprised to find this plugin, which claims to do exactly that, but the site hosting it is gone. Does anyone have a copy of this plugin? If not, has anybody written something similar?

Thanks!

This is the kind of thing I typically do with grasshopper, or a script. Here’s an example of a python script that selects all items with the same area as the first item selected when the command is run:

import Rhino
#Get a reference to the document
doc = Rhino.RhinoDoc.ActiveDoc
#Get all the objects in the document
objects = doc.Objects
#Get all the selected objects
selectedObjects = [o for o in doc.Objects.GetSelectedObjects(False,False)]
#try to get the first selected item, if it fails print a message to the command line
try:
    firstSelected = selectedObjects[0]
    objects.UnselectAll()
except:
    print "Select an object and re-run command"

#get the area of the first selected item
try:
    targetArea = Rhino.Geometry.AreaMassProperties.Compute(firstSelected.Geometry).Area
except:
    "Unable to measure object area"

#set up a list to hold all the items we want to select
toSelect = []
#for every item in the rhino document, try to get its area and compare it to the target area
for rhObj in objects:
    try:
        area = Rhino.Geometry.AreaMassProperties.Compute(rhObj.Geometry).Area
        if abs(targetArea - area ) < 0.01:
            toSelect.append(rhObj)
    except:
        pass
#for each item in the "to select" list, select it
for item in toSelect:
    objects.Select(item.Id)

Hope that helps!

1 Like

Hi @ andheum

I just discovered your script and trying to use-it with Rhino6, unfortunately it is freezing Rhino every time I use this script. Maybe you can update the script and make-it compatible with Rhino6?

Thank you.

It works fine on Rhino 6 when I test it. Something else must be going on. Does your document have a very large number of objects?

Yes, quite a lot.

If I do select everything Rhino is reporting something like this:
1853 curves, 6 surfaces, 450 polysurfaces, 54 extrusions, 35 Leaders, 70 linear dimensions, 157 texts added to selection.

this should definitely be added to rhino!

it could help in large files if, after giving the example object, you had to specify an area where to search for duplicates