Joincurves coplanar

Hi anyone may help me on a c# script?
I am trying to create a script which will be able to joincurves which are coplanar and intersect each other…
I have tried to use the joinCurves method but i don t understand what the IEnumerable parameter is.

here is my script :

List<Curve> myListOfNewCurves = new List<Curve>();
Plane plane = new Plane(point, vector);

for (int i = 0; i < myListOfCurves.Count ; i++)
{
  for (int j = 0; j < myListOfCurves.Count  ; j++)
  {
    if (myListOfCurves[i] != myListOfCurves[j] && Curve.PlanarCurveCollision(myListOfCurves[i], myListOfCurves[j], plane, 0.1))
    {

LineCurve joinedCurve = new LineCurve(myListOfCurves[i].PointAtStart, myListOfCurves[j].PointAtEnd);
myListOfNewCurves.Add(joinedCurve);
}
}
}
A = myListOfNewCurves;

Hi,

IEnumerable is a list or an array of curves. It’s the same principle as the Join Curves component.
Howeer if your curves are intersecting each other, this method won’t work. Are you trying to replicate Region Union ?

Hello
in rhinoceros it is not possible to join intersecting curves in a single curve. A curve is a “single” road with no intersection. It is opened or closed.
You could chose to begin the road and always take the right intersection … but you will end with some non linked roads.
From a closed self intersecting curve it is possible to make a single non intersecting curve but cutting the curve at the intersection. Here my component in my future plugin “Nautilus”

So it could be useful to know what you are after ?

Thanks for your answer
Could you please show an example of how to use the joincurves method
i wrote this but it seems to be wrong (I don t know how to deal with IEnumerable type…):
Curve joinedCurve = Curve.JoinCurves(myListOfCurves[i], myListOfCurves[j]);

My aim is to to be able to join curves which are coplanar and contiguous.
so i should have a set of two curves as shown below:


ow an example of how to use the joincurves method

Thanks for your answer
Could you please show an example of how to use the joincurves method
i wrote this but it seems to be wrong (I don t know how to deal with IEnumerable type…):
Curve joinedCurve = Curve.JoinCurves(myListOfCurves[i], myListOfCurves[j]);

My aim is to to be able to join curves which are coplanar and contiguous.
so i should have a set of two curves as shown below:

ow an example of how to use the joincurves method

This is not a trivial work as one curve belongs to 2 planes. So my guess is you need to use each 2 times. Planes could be made using the intersections.

What you show is not coplanar curve but aligned ones.

So at the end you ll have to use join curves and then split at kinks.
You could use Ienumerable with a foreach.

If you want an exapmple post tour script with curves internalise

Test joinCurves.gh (11.4 KB)

I guess that to join aligned curves I need to deal and test vectors?
What is the method to remove an iteme for a list in c#?
many thanks

I realise I don t even know how to use the move method… not sure how to use properly the Rhino documentation

Hello
here is a script that join curves then split then when there is not a continuity in direction.

  private void RunScript(List<Curve> myListOfCurves, ref object A)
  {
    List<Curve> myListOfNewCurves = new List<Curve>();

    Curve[] cs = Curve.JoinCurves(myListOfCurves);
    foreach (Curve c in cs)
    {
      List<double> lst_discontinuities = new   List<double>();

      double t0;
      double t1;
      double t;
      c.NormalizedLengthParameter(0, out t0);
      c.NormalizedLengthParameter(1, out t1);
      if (c.IsClosed) lst_discontinuities.Add(t0);
      while (c.GetNextDiscontinuity(Continuity.C1_continuous, t0, t1, out t))
      {
        lst_discontinuities.Add(t);
        t0 = t;
      }

      if (lst_discontinuities.Count > 0)
      {
        Curve[] curvesSplittedAtDistcontinuity = c.Split(lst_discontinuities);
        myListOfNewCurves.AddRange(curvesSplittedAtDistcontinuity);
      }
      else
      {
        myListOfNewCurves.Add(c);
      }
    }

    A = myListOfNewCurves;
  }

Test joinCurves LD.gh (6.4 KB)
From that


You get that

You can them test if there are on a plane. But this algorithm doesn’t necessary output planar curves.

2 Likes

Thank you very much i ll try that!