CreateFilletCurves method not working

I am trying to create multiple offsets by selecting two centre curves in c#

I am using the CreateFilletCurves method to create the fillet but I am facing a problem. I offset the centre curve and split successfully but when I try to fillet the split curves it works only in one direction.

double parameter1,parameter2;

            //Split First Curve
            c.ClosestPoint(events.First().PointA, out parameter1);
            c.ClosestPoint(events3.First().PointA,out parameter2);
            
            var paramsList = new List<Double>();
            paramsList.Add(parameter1);
            paramsList.Add(parameter2);
            var splitCurves= c.Split(paramsList);

            //Second Curve Split
            c2.ClosestPoint(events.First().PointA, out parameter1);
            c2.ClosestPoint(events2.First().PointA, out parameter2);

            paramsList.Clear();
            paramsList.Add(parameter1);
            paramsList.Add(parameter2);
            var splitCurves2 = c2.Split(paramsList);

 //Third Curve Split
            c3.ClosestPoint(events3.First().PointA, out parameter1);
            c3.ClosestPoint(events4.First().PointA, out parameter2);

            paramsList.Clear();
            paramsList.Add(parameter1);
            paramsList.Add(parameter2);
            var splitCurves3 = c3.Split(paramsList);


var splits =splitCurves.ToList();
var splits2 = splitCurves2.ToList();
var splits3 = splitCurves3.ToList();


        var filletcurves = Curve.CreateFilletCurves(splits.FirstOrDefault(), events3.First().PointA, splits3.FirstOrDefault(), events3.First().PointA, radius, false, true, true, doc.ModelAbsoluteTolerance, doc.ModelAngleToleranceDegrees);

            var filletcurves1 = Curve.CreateFilletCurves(splits.LastOrDefault(), events.First().PointA, splits2.FirstOrDefault(), events.First().PointA, radius, false, true, true, doc.ModelAbsoluteTolerance, doc.ModelAngleToleranceDegrees);

 doc.Objects.Add(filletcurves);
 doc.Objects.Add(filletcurves1);


this is image with split,split1,split2,split 3 curve arrays for reference

I am hard coding this to understand where is the exact error. Only one of the filletcurves is appearing but missing the second offset curve.

I am splitting the offset curves using intersection points and I get three curves(from a single curve). I remove the index 1 element and i am using the fillet method. Using the curve intersection points as curve endpoints in the filletcurves method.

The offset work when i try another curve in the code.

image

changed this part of the code to use the first curve from “splits” list

            var filletcurves1 = Curve.CreateFilletCurves(splits.FirstOrDefault(), events.First().PointA, splits2.FirstOrDefault(), events.First().PointA, radius, false, true, true, doc.ModelAbsoluteTolerance, doc.ModelAngleToleranceDegrees);

My guess was it is due to the curve direction but when you use the fillet in rhino, you can select any part of the curve to fillet this type of scenario.

Is there any other way I could make this offset work successfully in my code?

just a quick look at your code:

i recommend that you debug - in this case add to the document - all parameters you pass to the createfilletcurves-method:
add the two curves (1. parameter, 3. parameter)
add the two points (2. parameter, 4. parameter)

you also may want to add some code to check, if the split-function was successful and returns the expected number of curves.

i guess that something is wrong with those parameters, the points are choosen wrong or the split command did something unexpected due to other circumstances.

are you only handling lines ?

Hi Tom,

I have debugged the code. The split function works well.

Each curve is split into three smaller curves but just the fillet method is giving strange results. I have checked every parameter passed in the method by adding it to the document.

Currently, I am handling only lines.

still guessing:

did you check if
Curve.GetFilletPoints
Curve.CreateFillet
is doing the (partial) job ?

geometrically of course, there might be 4 solutions for an arc (red and green), end it is hard to distinguish if you pass the red Dot-Position.
maybe passing Curve-Parameters that will only enable one solution for a fillet will give better, more consistent results:
intersect each curve with a circle. (white)
this will give you the parameters at the green dot positions - ( this is the most visual approach, better performance might be possible with some curve-Domain juggling…)

1 Like

Adding the circle curve and getting the parameters from the curve intersection between the offset and circle worked! Thanks a lot for your help