Creating multiple lists with increasing values (but no 3rd level sublists) or flatten by one level

I have a set of values for which I want a list each of x number of value (in the image below, 3 increasing values). My list levels goes to @3 which I want to get down to @2 as later on in the script the additional level causes problems

In the above image, from the watch node I want each of the 7 values to increase by the values from the range node (in this case by 3x new values) without getting the additional list level @3. When flattening the list it flattens to much, I have to keep the list in sets of 3 for later on in my script.

After the flatten node I can probably make the sub-lists again every 3 values (I have this from a count node earlier in the script) but I assume I can create the sub-list of increasing values another way without the additional @3 level?

1 Like

I am not a master of this by anyones gauge, but my understanding is that a list of lists are enclosed in another list.

You may be able to try the reverse of what you are trying to achieve and instead chop your flat list into a list structure that matches the sublist of the other list so you can pass it through your code block.

Something like this might work for you.

Dynamo requires a list to hold multiple items whether they are lists, integers or Revit elements

I tried to chop and slice the list but ech time I get the same structure of 3 levels.

I’m trying to reduce levels as I have a list create combining other lists and here I have a list with sublists which I’m trying to avoid


You can see it in the snip above, the 3 sublists are part of list 2, while I want them to be their own list.

Maybe I can make the 3 sublists differently than in the OP and avoid the additional level?

I think that a list containing one level worth of sublists (as you show) will always be level 3? Or am I wrong? Flattening by one level will always result in a single level 2 list containing all the values.

1 Like

Can you show more of your graph? That would help.
And maybe i am missing something but “flatten while keeping the sublist
as shown in your image under the List.Flatten node will get you a list like
you shown under de + node.

EDIT
Now i think of it. You might need List.Join and NOT List Create at the end and / or
create a list from the list(s) with the least levels first.

Also

image

Maybe this helps.

1 Like

You are correct. I didn’t realise this behaviour.

With a list create there are no extra levels, one list per input is what you get.

In the end it didn’t matter I had those extra levels as the script worked as I wanted it to in the later stages, I was foreseeing problems that didn’t exist.

1 Like