Selection Filter


Cross-posting from a thread originally in Rhino for Windows:

Could someone show me how I would write a script to select the “densest” meshes:

  1. Start with nothing selected
  2. Loop over all visible meshes in the scene
  3. For each mesh, compute its bounding-box volume (or perhaps some other parameter like surface area), and the number of triangles/faces/vertices it contains
  4. For the current mesh compute the “density” as the ratio of the number of tris/faces/verts to the volume/surface are.
  5. If that density ratio is above a certain given parameter, select the mesh, otherwise don’t select it.
  6. At the end, report the number of selected meshes.

So, this would operate a lot like the Select->Select Small Objects tool (which is great, by the way). It would be an extension/generalization of that sort of functionality that I could customize to my needs. Generally speaking, the meshes that benefit most from ReduceMesh tend to be the smallest and/or have the most tris/faces/verts to begin with.

I don’t know exactly how scripting works in Rhino, but I would prefer if this ran without the need for any add-on plugins (like grasshopper), which would have to be purchased separately. Python would be perfect.

Edit: I now know that Grasshopper comes with Rhino, so that would be fine too.

Clay Budin

1 Like

I feel much anger in this one. Uhmmm, yes, yes. A path to the dark side he has taken.

1 Like

Two things to clear up; what do you mean by “select” and what do you mean by “visible”?

In Rhino ‘selecting’ is unambiguous, but in Grasshopper people typically use it (against my express wishes) to indicate the subset of a collection of data. I.e. “select” all the vowels in the collection {a, b, c, d, e, f} would yield another collection {a, e}.

Without plugins you cannot modify the selection states of Rhino objects from within Grasshopper.

Does “visible” refer to a specific viewport frustum, or just to all objects currently not hidden?

Measuring mesh areas and counting mesh faces is pretty trivial in GH once you have the meshes in there, but whether or not GH is going to be helpful depends on the exact result you’re after.