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.
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)