I uploaded two 3dm files in the posts below because a single example file with all objects was just too large (I think)…
I used RhinoCommon in a Grasshopper component to make some solid “cuboids”: 6 faced closed polysurfaces, with BrepSolidOrientation.Outward.
I checked in the Rhino UI, they look kosher.
I used this to try and fillet some edges.
private void FilletEdges(Brep[] cuboids, double radius, int[] edgeIndexes)
{
double t = DocumentTolerance();
double[] radii = new double[edgeIndexes.Length];
for(int i = 0; i < radii.Length; ++i)
{
radii[i] = radius;
}
for(int i = 0; i < cuboids.Length; ++i)
{
cuboids[i] = Brep.CreateFilletEdges(cuboids[i], edgeIndexes, radii, radii, BlendType.Blend, RailType.DistanceBetweenRails, t)[0];
}
}
Here is where I called it:
Surface[] outrPatches = new Surface[] { outrCuboidParameters.subsetPatches.outrPatches[0] };
Surface[] innrPatches = new Surface[] { innrCuboidParameters.subsetPatches.innrPatches[0] };
Brep[] cuboids = MakeCuboids(
//outrPatches,
//innrPatches
outrCuboidParameters.subsetPatches.outrPatches,
innrCuboidParameters.subsetPatches.innrPatches
);
AddTo(cuboids, C);
FilletEdges(cuboids, 0.03, new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 });
//FilletEdges(cuboids, 0.03, new int[] { 0, 2, 5, 8 }); // just the straight edges that connect outr and innr patches
AddTo(cuboids, B);
I initially just tried to fillet the edges that join my outer and inner patches (they are actually simple surfaces). I trimmed a generating surface using Surface.Trim
Anyway,
The Brep.CreateFilletEdges call creates about 30 invalid breps out of about 166 input breps.
I had already hand filleted 166 breps in the UI to see if the fillets were possible before I wrote the code to do it.
The hand fillets worked but filleting 166 breps by hand meant that I had to fillet ALL edges (not just the 4 that I really want to fillet) simply because it would be insanely difficult to only select the ones I wanted. To select all you just do a drag select.
So I tried to fillet all edges in code and it fails (about a 5th of the time) whilst filleting them in the Rhino UI works.
What is the UI doing to make things work? I am using DocumentTolerance().