How I can Joint Curves regardless of direction

Hello, I have a question.

I try to join these 7 curves(lines) in only 1 curve.

I use Curve.JoinCurves(). This function joins the end point of a curve with start point of another curve, and the result is 2 curves.

My question is: Are there any way to join all curves that intersecting in only 1 curve?

Thanks in advance

Yes using Join, but not as a closed curve. The ends of the curve will not coincide. See attachment for sequence to use. Not sure of the exact mathematical term, but a curve cannot have branches.
Joined Curve.3dm (43.4 KB)

Thank for your answer.
But I find a command or function that is able to solve the problem posed in a set of scenarios. i.e, I want to joint in a only 1 curve a set of curves that intersect, regardless of the direction of them.

Not all sets of intersecting curves can be joined into a single curve, due the to fundamental requirement of no branches. You can use Group to make any set of curves into a group if desired.

Thank davidcockery. All my lines come from closed curves, therefore there aren’t branches. i.e there are a closed external curve. The simplest case is 2 squares together, but may be more than two.
I try to use:
Curve.JoinCurves(ListCurves,0.01,false), but it does not work for my case. I will continue looking for a solution

Thanks again.

@mprades, if your curves are all closed like in above picture and maybe overlapping, you might have a look at _CurveBoolean command. There are equivalent methods in RhinoScript (vb) and Python if this is what you´re after:

rs.CurveBooleanDifference()
rs.CurveBooleanIntersection()
rs.CurveBooleanUnion()

c.

Thank you clement. These functions will be usefull for me in a future. But they don’t do what I want. I think what I ask is not possible. I try solve my problem from another perspective and perhaps these functions will help me.

Thanks.