Is there a way (w/o Grasshopper) to select all items on a layer that intersect with items on another layer?

Here’s the situation: I have a bunch of little polysurface items that are populated around a big mesh. I want to only keep the polysurfaces that are intersecting the mesh, and delete all the other ones that are inside and outside the mesh. Currently, I’m just deleting them manually, but it’s a big task. Is there any existing command that could in one way or another accomplish what I’m trying to do more quickly than manual labor? I could imagine various ways to script this in Grasshopper, but alas, that isn’t available for Mac yet (will it ever?)

Thanks Forum! Thanks Rhino, you’re my best friend.

An alpha version of Grasshopper is available in the current Mac Rhino WIP. This could also be done as a python script not needing grasshopper.

–Mitch

Fantastic, thanks for the alpha link.

How does one use Python scripting in RhinoMac? I am decently proficient with Python, so that sounds very interesting and fun.

EDIT: presumably this is a good place to start: http://developer.rhino3d.com/guides/rhinopython/get_started_with_rhinopython/

or

I am not a python guru - but here is a python script that seems to do the job in selecting only the polysurfaces that intersect a given mesh object. You may find that some of these operations are less verbose using the RhinoScriptSyntax library, but I am more familiar with RhinoCommon so that’s how I did it:

import Rhino
import Rhino.Geometry as rg
import System.Collections.Generic.IEnumerable as IEnumerable
import System.Guid as Guid
import Rhino.Input as ri
import Rhino.DocObjects as rdo
result, mainMesh = ri.RhinoGet.GetOneObject("Select a mesh",False,rdo.ObjectType.Mesh)
result, polysrfs = ri.RhinoGet.GetMultipleObjects("Select Polysurfaces to filter",False,rdo.ObjectType.Brep)
toSelect = []
for ps in polysrfs:
    psMeshes = rg.Mesh.CreateFromBrep(ps.Brep(),rg.MeshingParameters.Default)
    meshUnion = rg.Mesh()
    for mesh in psMeshes:
        meshUnion.Append(mesh)
    intersect = rg.Intersect.Intersection.MeshMeshFast(meshUnion,mainMesh.Mesh())
    if intersect and len(list(intersect)) > 0:
        toSelect.append(ps.ObjectId)
Rhino.RhinoDoc.ActiveDoc.Objects.Select.Overloads[IEnumerable[Guid]](toSelect)
1 Like

Thank you for your time andheum, this is very much appreciated.