Interpolate section curves between rails with adaptive spacing

As Inno said, it is always better to post a file. Devil is in the details

I think you could try to first have points that links each curve.

When you are happy with that. Extract the start and end points and make 2 polylines.
Then initialize your section curve, first line is beginning at start of 2 polylines.

Then search next point on each curve, the common parameter is the maximum of parameter for curve 1 and parameter for curve 2. It works here because for polyline parameter is linked to the control points. t=0 means first point, t=6 means 7th point … and if a line begin on point number N on a polyline it must be on point number N on the other polyline.

  private void RunScript(Polyline pl1, Polyline pl2, double minDistance, ref object A)
  {


    PolylineCurve plc1 = new PolylineCurve(pl1);
    PolylineCurve plc2 = new PolylineCurve(pl2);



    List<Line> lines = new List<Line>();
    lines.Add(new Line(pl1.First, pl2.First));
    double distanceOn1 = 0;
    double distanceOn2 = 0;


    for (int i = 0; i < 1000; i++)
    {
      double t1, t2;

      //We search point at a certain distance on each polyline
      if (plc1.LengthParameter(distanceOn1 + minDistance, out t1) && plc2.LengthParameter(distanceOn2 + minDistance, out t2))
      {
        double t = Math.Max(t1, t2);
        Point3d p1 = plc1.PointAt(t);
        Point3d p2 = plc2.PointAt(t);
        lines.Add(new Line(p1, p2));

        distanceOn1 = plc1.GetLength(new Interval(0, t));
        distanceOn2 = plc2.GetLength(new Interval(0, t));
      }
      else
      {
        break;
      }
    }

    A = lines;
  } 

I didn’t find a simple solution, perhaps there is a geometric one. Also this solution is not perfect as tubes are not parallel distance between point is not enough to ensure no collision.


But you can take some marging

You will need the Nautilus plugin

Interpolate section curves between rails with adaptive spacing Laurent Delrieu Nautilus.gh (17.0 KB)

You could also change the angle with this method.

2 Likes