Tangent to a Brep

I want to find two tangent lines to a given brep which pass through a specified point.
It is easy to draw these lines on rhino by command _line _Tangent.

I made a GH which can find the tangent lines (see the attached file). But any components (or plug in) can do the same thing?

GK 312C.gh (14.7 KB)

  private void RunScript(Curve curve, Point3d point, double seedParmameter, ref object A)
  {
    double t;
    curve.GetLocalTangentPoint(point, seedParmameter, out t);
    A = curve.PointAt(t);
  }

LocalTangentPoint.gh (14.2 KB)

Dear Mahdiyar, thanks a lot!
I encountered a problem. Please see the attached! What should I do??

It seems you’re using Rhino 5, This script supposed to work on Rhino 6.

This one must work on Rhino 5 too:

private void RunScript(Curve curve, Point3d point, double seedParmameter, ref object A)
{
    var c1 = (new Circle(point, 1.0)).ToNurbsCurve();
    double t1;
    c1.ClosestPoint(curve.PointAt(seedParmameter), out t1);
    Line l;
    Line.TryCreateBetweenCurves(curve, c1, ref seedParmameter, ref t1, false, true, out l);
    A = curve.PointAt(seedParmameter);
}


IntervalSelection.gh (25.6 KB)

Dear Mahdiyar
Yes, I use Rhino 5. I can execute your new script now. Thanks a lot!

Here’s a less accurate way without scripting:

20_04_07_tangent_to_curve_mrtn.gh (7.3 KB)