Sorting curves

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

};
SortListsss(data);

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

when i right click i dont see that option

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

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.
20170921-2

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];
        Lot = List.AddItemToEnd(BP[0], Lot);
        BP = List.RemoveItemAtIndex(BP, 0);
        cnt = cnt - 1;
            i = 0;
            while (i < cnt)
            {
            	current = BP[i];
            	condition = occupied.DoesIntersect(current);
            	if (condition == true)
            	{
					Lot = List.AddItemToEnd(current, Lot);
					BP = List.RemoveItemAtIndex(BP, i);
					cnt = cnt - 1;
					i = 0;
           		}
           		else
           		{
           			i = i + 1;
           		}
			}
    }
    return = Lot;
}

};
CreatePolyCurve(curves);

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

1 Like