I’m doing some development using Brep.JoinBreps method. If I try to use it on this file JoinBreps.3dm (636.0 KB) the resulting Brep is an open polysurface, but if I call the “Join” command it makes a closed polysurface, ¿do you know why is that difference and how I can get same results as Join command through Rhinocommon?
This is the code I use to join them
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var selected = doc.Objects.GetSelectedObjects(false, false);
List<Brep> brepsToJoin = new List<Brep>();
foreach (var obj in selected)
{
if (!obj.Geometry.HasBrepForm)
{
continue;
}
var brep = obj.Geometry as Brep;
brepsToJoin.Add(brep);
}
var result = Brep.JoinBreps(brepsToJoin,doc.ModelAbsoluteTolerance);
if (result != null && result.Length == 1)
{
doc.Objects.AddBrep(result[0]);
return Result.Success;
}
RhinoApp.WriteLine("Error joining breps");
return Result.Failure;
}
Using the List command you can see the exact edge tolerances after the Join command has run. It looks like there are multiple edges that have a tolerance above the document tolerance of 0.001. It may be that in the code of the Join command, the join tolerance is set to 2*document tolerance (I see that in more examples by McNeel staff).
What I typically do is to keep joining with less and less strict tolerances, until either the join has succeeded or the upper limit on tolerance has been reached.
I think the reasoning is that if each edge moves by at most the document tolerance, the maximum distance covered by two edges to join up is twice the document tolerance.
Thanks for your guesses, I’ve tried to join with tolerance in steps of 0.001 and it makes a closed polysurface with 0.003 in this case, with 0.001 and 0.002 it makes an open polysurface.
Do you know which logic is using McNeel for this operation in their command? In this case they prioritize 0.003 result above 0.001 despite the document tolerance is 0.001. Do they prioritize a “Solid” result over an “Open” or do they just start testing from 0.01 to 0.001 and they return the first join returning a value?