Disjoint solids - we need a command to separate them

In the file attached, there are two “disjoint” solids. These have (probably) been created by ToNurbs-ing disjoint meshes via some kind of automatic routine, they are part of a 3D building download from a topographic site. There are many such occurrences in the download, this is just a couple of examples.

Currently the only way to have these as distinct volumes is to Explode and re-Join. CreateVolumes does not do the job correctly, even with DeleteInput=Yes, the original disjoint solid remains in both cases, and on the larger of the two one does not even get the main volume as a separate object. Plus, one can only do one object at a time.

We need a command SplitDisjointBreps or something similar.

Disjoint solids.3dm (3.1 MB)

1 Like

_CreateSolid works in this case.

If a dedicated command is made for this, maybe it should be called NonmanifoldSeparate because it would be the opposite of NonmanifoldMerge.

This seems like something CreateRegions should do. I’m not sure why but it’s keeping some of the pieces together on the more complicated example. In the meantime this script should do what you want.

using System;
using Rhino;
using Rhino.Input;
using Rhino.Geometry;

RhinoGet.GetOneObject("Select brep", false, Rhino.DocObjects.ObjectType.Brep, out var rhObj);

var b = rhObj.Brep();

Brep[] pieces = Brep.SplitDisjointPieces(b);

if(pieces.Length > 1)
{
    RhinoDoc.ActiveDoc.Objects.Delete(rhObj, false, false);

    foreach(var p in pieces)
    {
        RhinoDoc.ActiveDoc.Objects.AddBrep(p);
    }

    RhinoApp.WriteLine(string.Format("Split brep into {0} pieces", pieces.Length));
}
else
{
    RhinoApp.WriteLine("Brep doesn't have disjoint pieces");
}

Hi Joshua,

OK, you’re saying that Brep.SplitDisjointPieces()should work when CreateRegions doesn’t? I will do some testing on the file I have here which has about 1000 of those objects and see what it does, thanks! I was also looking at scripting simply an Explode/Rejoin for each brep.

Not really. CreateRegions was written to find the different closed regions on nonmanifold breps. Usually after running the NonmanifoldMerge command. The example here in the docs is what I’m talking about:

From what I know about how it works (having messed with it a bit) I thought it also should have handled your examples. My thought here was that instead of a new command it might be better to figure out how to make an existing command with very similar behavior to do what you’re asking. If you know the brep has a bunch of disjoint pieces that don’t intersect I’d just use that script.

Please let me know how it goes!