Making one List from Multiple Sublists with Sublist Length

In my attached screenshot I have commented on the 4 nodes that I talking about.

My overall idea that I am trying to accomplish is to determine which conduits have a pull box intersecting with them.

I have been able to determine which conduit has a box intersecting with it. Now I am trying to take the conduit back and reference which conduit run it came from.

In my screenshot here I have 10 conduit runs. In the ‘Elements in connected network’ node I have all the elements in each of those runs.

The ‘List.SublistsContain’ node is search for which run contains the conduit that is intersecting with a box.

My issue is now I have a list of in this case 3 sublists of booleans. I need to combine the 3 sublists into one list with the length equal to one of the sublists. In the new list if one of the corresponding values in the sublists equal true it will be true otherwise it will be false.

So I haven’t really been able to find a out of the box node for this.

(It is possible I am overlooking it though.)

I am thinking I need some sort of for loop to go through each sublist and return either a true or false into the corresponding index of a new list. I’m not a coder by any means but I have started this which no surprise to me doesn’t work. But hopefully its a start in the right direction.

Set the level for the seq input of the List.SublistsContain to level 2 or 3 (I havented used the node so I can’t say for certain). Then set the lacing to cross product.

When I set the lacing to cross product and Level to 2 I get 294 results.

When I set the lacing to cross product and Level to 3 I get 30 results. (The same result I originally got.)

Thanks for the suggestion though.

Then that’s the correct count. 3 items, tested against 98 items, is 294 test (3*93 = 294).

From there use a List.Transpose so you get sublists of 3, and use a List.Contains to find if any sublist has true, and use that list of Booleans to filter your original list.

Thanks for the help.

Unfortunately I was not able to get your solution to work.

In the end though I have taken things in a slightly different direction as it wasn’t getting me the results that I wanted. I was able to get the result that I wanted just in a different way.

Can you share that method so that others can learn from your effort?

The reason I didn’t originally was because it’s sort of different from my original question. I took a completely different direction and I’m no longer trying to combine lists.

So what I was trying to do originally was figure out which boxes where intersecting with which conduit. After that I didn’t to determine which conduit/box intersection was with what conduit run. (Hope that doesn’t sound too confusing.) The plan was/is to determine the length of the sections of a conduit run to see if the section is over the allowed bends or length.

In the screen shot below I have changed the number of conduit runs in my test project (10 was too many to sort through while trying to figure everything out.) But I’m still taking the total conduit runs (the polycurves). I’m now taking the center point of the boxes and seeing which conduit run (polycurve) it falls on. After that I end up with a list of repeating polycurves. So now I take the list of boxes (Watch List - Lower Left) and put them into a list based on which conduit run (polycurve) they are on. The only way I was able to figure out how to do this was with Python. Which I have included below.

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
runlist = IN[0]
boxlist = IN[1]
boxcount = IN[2]
runcount = IN[3]
boxes = boxcount - 1
runs = runcount - 1
out =  []

for runnum, runname in enumerate(runlist):
	for boxnum, boxname in enumerate(boxlist):
		box = boxname[0]
		if runname == box:
			out.insert(boxnum, runnum)

# Place your code below this line

# Assign your output to the OUT variable.
OUT = out

This gets me the result I was looking for in my original question just a completely different way.

Now I need to figure out how to get these boxes in order on how they are placed on each conduit run. Still working on that.

Hope that helps someone out.

1 Like