Multiple If statements with lists

I am creating a graph that has two lists. Depending on the users input (in this case 1, 2, or 3) I want to either send through the data from list 1, list 2, or a combination of the two. In the example below, I am using the Number on the top left to represent the users input. There are two lists, one with 6 items and one with 13. Based on my “logic” I expect the following results: user enters 1 and gets list 1 with 6 items or user enters 2 and gets list 2 with 13 items or user enters 3 and gets a combination with 19 items.

The problem is that whatever number the user enters, I keep getting list 1 regardless. The first if statement is updating properly but the second if statement seems to not care.

Thoughts? Did I miss something stupid? :slight_smile:

Hi @rdeardorff

Use ScopeIF node instead:


Keep in mind ScopeIf only works if the inputs are self contained as it only runs one input at a time. For this reason it’s good to get familiar with the index method that @Kulkul showed.


Since the user is feeding a number, you could build a list of all the lists (including a flattened version of the combo list), subtract one from the selected number, get the item from the combined list at the resulting index. I’m a single line of design script it looks something like this:

[list1, list2, DSCore.Flatten([list1,list2])][x-1];

In node form it would be a List.Create node followed by a List.GetItemAtIndex node.

1 Like

You are inputting a value into an IF node, this if node only works with a boolean value, so you should place and == node / “x==1” node in between.

I also recommend using a number slider as End user input.

@Daan @JacobSmall I simplified the graph to illustrate the problem I am having with a bigger graph. In the actual graph, users are picking an option in a Data Shapes UI window. The results are either 1, 2, or 3 which are then fed into the logic statement that I posted here.

@Daan I do not understand what you mean by this. Both of my IF statements are currently fed with booleans into the test input.

@Kulkul @JacobSmall I will try the Index method you both have illustrated. I already tried the ScopeIf and it crashed my graph (or just ran so slow that I gave up waiting for it). I will let you know how it goes.

Okay so you want to have 1,2 or 3 as input and according to this you want to output an input given?

@Daan No. There are two lists (two different grouping of views from a model in this case…one contains sections, elevations, and details…the other contains plans). The user is picking whether they want the graph to deal with sections/elevations/and details only…plans only…or everything. Their selection outputs a 1, 2, or 3 which represents their selection. That is fed into the If statements to produce the resulting list that they want.

Okay, i think i know a simple solution, i am working on it right now.

Is this what you need?

E = [Imperative]
if(A==1) {return B;
}elseif(A==2) {return C;
}elseif(A==3) {return D;

1 Like

@Daan That did work. Here is that method worked into a larger portion (still somewhat simplified) of my graph. I forgot to mention that the two inputs the user gets produce a 1 and a 2 and if they select both the Math.Sum node produces a 3.

I am glad i could help :slight_smile: