Wish: additional option for Split (or "Boolean Trim"?)

Hi,

It would be helpful to have the ability to either delete or select/group parts of the resulting split objects that are inside of the splitting objects, if the “splitters” are closed volumes.

Very often we split sets of objects with another large set of closed volumes, but later on removing the ‘trimmed out’ leftovers takes a lot of manual picking work.

With volumes only, BooleanDifference works great, but if the object(s) to be split is not a volume, then there seems to be no easy way to “trim” with solid volumes.
I would envision this either as a parameter in Split command, or a separate command (TrimWithClosedObjects or BooleanTrim?)

thank you,

–jarek

1 Like

Here is a sample file of the typical issue: I want to split the white surface with the set of blue ones, but remove all he pieces inside of the blue parts. In many cases like this one it is quite tedious to separate the resulting pieces. What I am looking for is basically to trim-out parts of white surface with blue solids.
Or maybe I am missing something obvious?

Split_problem_sample.3dm (1.6 MB)

I don’t a simple way to do this.
Basically you need to Intersect each polysurface with the surface, one at a time, then Hide the polysurface and Trim the surface with the intersection curve.
Then repeat with the next polysurface, one at a time.

That’s not a good way if you have 100’s of holes or slices to trim out, that’s why I was suggesting an automated way to do it. The check should be a containment and I am sure math geniuses @ McNeel could code that. Whatever resulting piece is contained within the splitter solid should be removed. Kind of Boolean-style.
In many cases it would save a lot of time of by-hand picking. We run into this quite often.

1 Like

Any other suggestion of how to do it NOTone-by-one?

I tried scripting but somehow the Rhino.IsPointInSurface method did not seem very reliable (tried duplicating border of each resulting split surface, dividing into 10 points and testing each point for inclusion in each of cutting solids. If all points were included inside a single solid, within tolerance, that means containment/deletion). But it did not work as expected so far…

Hi Jarek,
When I see your example file I think it can be done with some scripting.

  1. Copy the surface you want to split (lets call it object A)
  2. Offset that surface to a solid (lets call it object B)
  3. Run a script which loops through the obects to subtract and do a BooleanDifference with object B
  4. Explode the resulting splitted object B
  5. Loop through the explode objects and compare a test point on each surface if its on surface A. If not delete the object.

You should be left with the splitted input surface.
Maybe I can write a quick n dirty script doing this steps if I find time later

gr, Tobias

1 Like

Yes !

Boolean-style trimming would be a useful tool.
I missed it many times too.

Rhino 6 has “SelVolumeObject” command you can use to select everything inside the volume after the split. It works on a single volume so you’ll need to automate it with a script. Following dirty script is mostly relying on existing Rhino commands to offset the bounding volumes first (you can play with tolerance, currently 0.2) then select and delete with “SelVolumeObject”.

Script should be faster once “OffsetSrf” and “SelVolume” are replaced with corresponding RhinoCommon methods.

import rhinoscriptsyntax as rs

objects = rs.GetObjects("Pick bounding volumes", preselect=True)

if objects:
    for object in objects:
        rs.SelectObject(object)
        rs.Command("OffsetSrf Solid=Yes 0.2 Enter")
        rs.HideObject(object)
        rs.Command("SelLast")
        o_volume = rs.SelectedObjects()
        rs.Command("SelVolumeObject")
        rs.DeleteObject(o_volume)
        del_parts = rs.SelectedObjects()
        rs.DeleteObjects(del_parts)

Don’t forget to split your surface first before trying it.

2 Likes

Thanks for the reminder ! :slight_smile:

This is certainly useful for closed objects.
Still I would like a trimming command working according to (poly)surfaces normals…

Regards

1 Like

@Tobias - thanks for the suggestion - this method would work on the attached sample, but if case if the object to split is a polysurface, curve or a combination of many types, it would not work. I am looking for a broader solution.

@spineribjoint1 - great suggestion, I was not aware of the SelVolumeObject new command. It does exactly what is needed which goes to show you the math and piping for such thing is already there in Rhino, so wrapping it up into a command should be possible. I will take a look and test the script soon.

thanks!

–jarek

Ok, scripting the “SelVolumeObject” works well. I wrote another version of the script with some extended functionality.

What is nice about the SelVolumeObject command is that it also works with closed meshes as input. So having that in the script I used render-mesh as the slightly offset volume instead of offsetting polysurfaces, which in many cases is slower and less reliable.

What is NOT nice about the SelVolumeObject command, it does not work well with Groups. Meaning, if the contained object is a part of a group and the whole group is not contained in the volume, it will not be selected.

So this script works with render-meshes, and does some extra work to maintain original object groupings, with an option to keep the “in-volume” objects that will also retain their original groupings (as duplicates). We work with groups a lot so it only makes sense. You can even group some individual input objects and sigle-object groups, so if the result is tons of pieces of each, they will end up neatly grouped.

Here is the script for anyone interested: DIG_BooleanSplitTrim.rvb (5.0 KB)

@Pascal - any chance we could have an option in SelVolumeObject command to ignore Groups?
And in general, could the above functionality be added as a full-fledge Rhino command (BooleanTrim)? It’s nice to be able to script this to some degree but for cleanness and speed a native command would be great. It seems like such a basic functionality that IMHO it should be in the base Rhino toolset among other fancy trim/split/Boolean capabilities.

@Dale - could we add a Wish for SelVolumeObject RhinoScript method ?

many thanks,

–jarek

1 Like

https://mcneel.myjetbrains.com/youtrack/issue/RH-47605

– Dale

1 Like