Fillet problem

Hello,

I’m trying to fillet between these two lines, the lines are not on the same plane.

When the anthem fillet command is applied the fillet works as it should.

But if you try to apply the code then it’s not working:
var Arc =Curve.CreateFillet(a,b,radius, domain1, domain2);

how can i get around this?

TesteFillet.3dm (22.3 KB)

maybe easier to understand why it is not working with your code example.

Did you add the correct domain values? Perhaps checking the domain values by adding a point at the domain helps to verify this.

Hello @sujal ,

You can use this example.

        var gc1 = new GetObject();
        gc1.DisablePreSelect();
        gc1.SetCommandPrompt("Select first curve to fillet (close to the end you want to fillet)");
        gc1.GeometryFilter = ObjectType.Curve;
        gc1.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve;
        gc1.Get();
        //if (gc1.CommandResult() != Result.Success)
        //    return gc1.CommandResult();
        var curve1_obj_ref = gc1.Object(0);
        var curve1 = curve1_obj_ref.Curve();
        if (curve1 == null) return ;
        var curve1_point_near_end = curve1_obj_ref.SelectionPoint();
        if (curve1_point_near_end == Point3d.Unset)
            return ;

        var gc2 = new GetObject();
        gc2.DisablePreSelect();
        gc2.SetCommandPrompt("Select second curve to fillet (close to the end you want to fillet)");
        gc2.GeometryFilter = ObjectType.Curve;
        gc2.GeometryAttributeFilter = GeometryAttributeFilter.OpenCurve;
        gc2.Get();
        //if (gc2.CommandResult() != Result.)
        //    return gc2.CommandResult();
        var curve2_obj_ref = gc2.Object(0);
        var curve2 = curve2_obj_ref.Curve();
        if (curve2 == null) return ;
        var curve2_point_near_end = curve2_obj_ref.SelectionPoint();
        if (curve2_point_near_end == Point3d.Unset)
            return ;

        double radius = 20;
        var rc = RhinoGet.GetNumber("fillet radius", false, ref radius);
        //if (rc != Result.Success) return rc;

        var join = false;
        var trim = true;
        var arc_extension = true;
        var fillet_curves = Curve.CreateFilletCurves(curve1, curve1_point_near_end, curve2, 
        curve2_point_near_end, radius,false, false, true, doc.ModelAbsoluteTolerance, 
        doc.ModelAngleToleranceDegrees);
        if (fillet_curves == null /*|| fillet_curves.Length != 3*/)
            return ;

        foreach (var fillet_curve in fillet_curves)
            doc.Objects.AddCurve(fillet_curve);
        doc.Views.Redraw();
        return ;

filletTest.3dm (22.5 KB)

Use blend curves instead of fillet.

Hi @Popoff ,

Blend is not true arc, and I want true Arc.

Thanks

public static Arc CreateFillet(
Curve curve0,
Curve curve1,
double radius,
double t0Base,
double t1Base
)

note: the last 2 parameters are Curve-Parameters - not points -

use

to get the parameter

hope this helps - did not test or digged deeper into your code. kind regrads - tom

Hi @MatrixRatrix,

This works on the first file you posted - TesteFillet.3dm

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var go = new GetObject();
  go.SetCommandPrompt("Select first curve to fillet");
  go.GeometryFilter = ObjectType.Curve;
  go.Get();
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  var c0 = go.Object(0).Curve();
  var p0 = go.Object(0).SelectionPoint();
  if (null == c0 || !p0.IsValid) 
    return Result.Failure;

  go.SetCommandPrompt("Select second curve to fillet");
  go.EnablePreSelect(false, true);
  go.DeselectAllBeforePostSelect = false;
  go.Get();
  if (go.CommandResult() != Result.Success)
    return go.CommandResult();

  var c1 = go.Object(0).Curve();
  var p1 = go.Object(0).SelectionPoint();
  if (null == c1 || !p1.IsValid)
    return Result.Failure;

  var results = Curve.CreateFilletCurves(
    c0, p0, 
    c1, p1, 
    20, 
    false, false, true, 
    doc.ModelAbsoluteTolerance,
    doc.ModelAngleToleranceDegrees
    );

  if (null == results || 0 == results.Length)
    return Result.Failure;

  foreach (var crv in results)
  {
    var id = doc.Objects.AddCurve(crv);
    doc.Objects.Select(id, true);
  }
  doc.Views.Redraw();

  return Result.Success;
}

With the second file you posted - filletTest.3dm - if you run Rhino’s Fillet command with a radius of 20, you see this:

Unable to fillet the curves. The fillet radius may be too big or the curves may not be on the same plane near the fillet.

– Dale

1 Like