# Sorting curves

#1

I have a list of unaranged curves and I want to be able to organize them in a that lists them by intersection. How do you use the Geometry.DoesIntersect in a codeblock?
Here is my code. Why isn’t it working?

def SortListsss(BP:var[])
{
Lots = {};
Lot = {};
cnt = List.Count(BP);

``````return = [Imperative]
{
while (cnt > 0)
{
occupied = BP[0];
BP = List.RemoveItemAtIndex(BP, 0);
cnt = cnt - 1;
i = 0;
while (i < cnt)
{
current = BP[i];
condition = Geometry.DoesIntersect(current, occupied);
if (condition == true)
{
BP = List.RemoveItemAtIndex(BP, i);
cnt = cnt - 1;
i = 0;
}
else
{
i = i + 1;
}
}
}
return = Lot;
}
``````

};
SortListsss(data);

0 Likes

#2

It’s actually `occupied.DoesIntersect(current)`. You can always right click on a node and select Node to Code to translate that node (or selection of nodes) to a code block.

1 Like

#3

when i right click i dont see that option

0 Likes

#4

Select the node or group of nodes, and right click in the graph background, not on the node directly.

0 Likes

#5

The description that appears on hovering over a node also usually gives an idea of the number of arguments required within parenthesis. Not always obvious, but quickly gives a fair idea.
In the case of Geometry.Intersect, only one.

0 Likes

#6

Is there a way to create a polycurve from a list of joined curves?

From the picture above, I have organized the curves so that it’s easier for me to create a closed polycurve for each building pad from the picture. Is there a way? Here’s my code now so far:
def CreatePolyCurve(BP:var)
{
Lots = {};
Lot = {};
cnt = List.Count(BP);

``````return = [Imperative]
{
while (cnt > 0)
{
occupied = BP[0];
BP = List.RemoveItemAtIndex(BP, 0);
cnt = cnt - 1;
i = 0;
while (i < cnt)
{
current = BP[i];
condition = occupied.DoesIntersect(current);
if (condition == true)
{
BP = List.RemoveItemAtIndex(BP, i);
cnt = cnt - 1;
i = 0;
}
else
{
i = i + 1;
}
}
}
return = Lot;
}
``````

};
CreatePolyCurve(curves);

0 Likes

#7

@elvisbikoba You could try the code I’ve shared here…

1 Like