# Weave List using Boolean Pattern

I have a list of boolean values that I want to use as a means to weave 2 lists together. I’m uncertain how the list combination nodes work and would appreciate any help or direction.

The pattern looks like something below, with the 2 preceding lists.

I thought of changing the pattern to numbers 0=False and 1=True, but I can’t find a way to weave the lists using that combination.

Thanks

Try Combine by Pattern from archi-lab package.

Thanks Konrad, I tried the Combine by Pattern node. However, it is only giving me 21 values in the output, when there should be 111 values

If it’s just two lists and a boolean pattern, it might be easier to do this with some of the default nodes:

1 Like

I would do what Dimitar is suggesting. Combine by pattern works on two lists of exactly equal length. That means that the input Boolean pattern has to be 110 items but so does list 1 and list 2 .

With this kind of input (lists with different lengths), it would actually have to be something (more or less) recursive. Basically (if I understand you correctly) you want to cycle through the whole list of booleans and for each item either take the first item in the list of lines or the list of arcs (and then go into the next iteration with that first item dropped from its respective list). You could do that with a Python script:

booleans = IN[0]
lines = IN[1]
arcs = IN[2]
elementlist = list()
for boolean in booleans:
if boolean == True:
elementlist.append(lines[0])
lines.pop(0)
else:
elementlist.append(arcs[0])
arcs.pop(0)
OUT = elementlist

I haven’t tried this, so it might be buggy…

EDIT: I just love the way this forum swallows all the indents when pasting a script here.

@Dimitar, I tried your method in some samples and it works fine, although when I apply it to my lists of Lines and Arcs to combine, it causes any of the Arc values to become Null. Could this be a program issue?

@Andreas, I’m not too familiar with Python Script, however when I copy and paste the script in and try running it with:

• INT[0] = Boolean Pattern
• INT[1]=True Values (Lines)
• INT[2]=False Values (Arcs)
It does not seem to work, below is how the Script looks like in the node.

Appreciate all the assistance!

Indentation. Try this:

Thanks Konrad for clearing that up. It works now!

Appreciate all the help everyone

Sorry, I was under the impression that the lists were of the same length.

No problem Dimitar, appreciate the help regardless, I think I should of explained my issue more. But since there has been a few ways to tackle this, at least I know for the future how to solve it!