Grouping the list

Hi, everyone

Is there a way to create the list shown below on a standard node or Python script?

We also upload frustrated Python scripts.

Thank you

Home_01.dyn (2.4 KB)

I think this will help you as well:
https://forum.dynamobim.com/t/sorting-list-based-on-several-variables/21005/5?u=paultus
It might be worth going through more than just that solution.

PauLtus san

Thank you for your reply.
I saw the thread you introduced.

However, the goal is to create a combination rather than sorting the list.

Therefore, as shown in the figure shown above, I would like to tell you how to generate a list like the one on the right from the given list.

The thread you taught was very helpful. Thank you very much.

Yes, but with Design Script …

a;
b = [Imperative]
{
	c = List.Count(a);
	d = {};
	e = 0;
	while (e < c)
	{
		f = 0;
		g = 0;
		while (g < c)
		{
			d[e][0] = a[e];
			if (List.LastItem(d[e][f]) == List.FirstItem(a[g+1]))
			{
				f = f + 1;
				d[e][f] = a[g+1];
				g = -1;
			}
			else
			{
				g = g + 1;
			}
		}
		e = e + 1;
	}
	return = d;
};
5 Likes

Vikram Subbaiah san

Design script worked as expected.
This script can check the route of piping etc.

Thank you very much for helping me.

1 Like

Sorry for misunderstanding your question then. :confused:
I’m glad that @Vikram_Subbaiah was able to solve it (consider giving him a like :wink:).

3 Likes

To do so, the script might have to be altered to check equality for objects.
Also, it might work with open loops, but might fail with closed loops.

You might also find the Grouping Curves script I’ve posted here helpful.

3 Likes

PauLtus san

Thank you for your kind reply.
The sort that I taught was also very helpful!

1 Like

Vikram Subbaiah san

GroupCurves design script is also great!
I will use it by all means.

thank you everybody.

2 Likes