Below is an attempt to multithread SplitBrepMultiple
using node-in-code. My initial thought was just to get the output in the same format (trimmed srfs and open breps, not just trimmed srfs), but I’m finding there must be some other things the OOTB component does which make it faster than just Brep.Split
. I’m also using Clash
to cluster the splitters.
try_multi_BW.gh (16.3 KB)
Node-in-code
private void RunScript(DataTree<object> B, DataTree<object> C, ref object R)
{
Grasshopper.DataTree<Brep> results = new Grasshopper.DataTree<Brep>();
int n = Math.Min(B.Paths.Count, C.Paths.Count);
Brep[][] fragments = new Brep[n][];
Parallel.For(0, n, (i) => {
///Node in code to get consistent results from OOTB Split Brep Multiple
///https://discourse.mcneel.com/t/calling-grasshopper-components-in-c-for-grasshopper/66610/4
var func_info = Rhino.NodeInCode.Components.FindComponent("SplitBrepMultiple");
var func = func_info.Delegate as dynamic;
var result = func(B.Branches[i][0], C.Branches[i]);
Brep[] b = new Brep[result.Count];
for (int j = 0; j < result.Count; j++)
{
b[j] = (Brep) result[j];
}
fragments[i] = b;
});
for(int i = 0;i < n;i++){
results.AddRange(fragments[i], new GH_Path(i));
}
R = results;
}
-Brian