Trim a line

Can anyone point me in the right direction please: I wish to write C# code to trim a line - given a second intersecting line to trim with .

Here you have three examples of how to trim:

C# version(s):

// using Rhino.Geometry.Intersect;

private void RunScript(Curve C1, Curve C2, double T, ref object CurveCurve, ref object Curve_t)
{
    var tol = 0.001;

    // Intersect Curv 1 with Curve 2:
    var isect = Intersection.CurveCurve(C1, C2, tol, tol);

    // Trim at t (= between 0..1)
    var t = isect[0].ParameterA;
    CurveCurve = C1.Trim(0.0, t); // White color

    // Trim away t with slider
    Curve_t = C1.Trim(0.0, T);    // Black color
}

trim_with_curves.gh (11.6 KB)

// Rolf

In addition to RIL’s answer, you could use one of the two LineLine intersection methods (this and this) available in RhinoCommon. In particular if you’re looking to intersect infinite lines.

Also, be sure to follow these tips when posting topics (always helps with a file/some code).

that is just soooo (as they say) helpful
Thanks lot