I don't think you can do that, exactly. There are two distinct steps that require human input: mapping the exploded surfaces, and deciding which mesh faces belong together, in order to perform the boolean. So, start with the first: getting mesh faces to texture map. Here is a RhinoScript to do that:
Code: Select all
Sub MeshFacesFromNurbsObjects
Dim objects, surfaces, meshes
objects = Rhino.GetObjects("Select objects to mesh", 24)
If IsArray(objects) Then
surfaces = Rhino.ExplodePolysurfaces(objects)
If IsArray(surfaces) Then
Rhino.HideObjects objects
Rhino.UnselectAllObjects
Rhino.SelectObjects(surfaces)
Rhino.Command "ExtractRenderMesh"
Rhino.DeleteObjects(surfaces)
End If
End If
End Sub
If you read through that (RhinoScript reading pretty much like plain english), you'll see that it asks you to select some NURBS objects, makes duplicates of those you select, hides the originals, explodes the duplicates into surfaces, extracts meshes for each, and then deletes the temporary surfaces. Which means that you now have a bunch of mesh faces that you can texture map.
Once you've done your mapping, we have a second script:
Code: Select all
Sub JoinAndDifferenceMeshFaces
Dim subtractThese, fromThese
subtractThese = Rhino.GetObjects("Select mesh faces to subtract", 32)
If IsArray(subtractThese) Then
fromThese = Rhino.GetObjects("Select mesh faces from which to subtract", 32)
If IsArray(fromThese) Then
Dim subtractThis, fromThis
Rhino.UnselectAllObjects
Rhino.SelectObjects(fromThese)
Rhino.Command "Join"
fromThis = Rhino.LastCreatedObjects
If IsArray(fromThis) Then
Rhino.UnselectAllObjects
Rhino.SelectObjects(subtractThese)
Rhino.Command "Join"
subtractThis = Rhino.LastCreatedObjects
If IsArray(subtractThis) Then
Rhino.MeshBooleanDifference fromThis, subtractThis
End If
End If
End If
End If
End Sub
This script prompts for two sets of meshes: those from which to subtract, and those to subtract. Once it has those, it joins each set, and then performs a boolean difference on the joined pieces.
I could post an .rvb file containing these, but it might be nice to get a little familiar with how to enter scripts yourself, so find the RhinoScript editor, paste the two scripts into it, and save it as an .rvb file somewhere on your system. Whenever this .rvb is loaded, you will have two script commands available (named for the subs in the code):
- MeshFacesFromNurbsObjects
- JoinAndDifferenceMeshFaces
You can then create a toolbar button for calling these, where the left- and right-button commands might be written like this:
- -RunScript (MeshFacesFromNurbsObjects)
- -RunScript (JoinAndDifferenceMeshFaces)
Hopefully this gives you an idea how to get where you want to be.