Making a list by summing values


This is my first post here. I am trying to make a list of values that are generated by summing together values in another list.

I want to place a collection of families that have the parameter “width.” I am reading the width parameter of each type into a list. So I have all of these values, but they vary as you might expect, so the list is something like:

[0] 7.00

[1] 6.00

[2] 7.00

[3] 5.50


What I want to do is place the first family at 0, then the next one at 7, the next at 13, then 20.

So I want to add the width of the previously placed one to the x value of the next one, then repeat till they are all placed. I am trying to get a consistent “padding” in between elements. I have it working just fine to place them using a sequence where the spacing is equal, but this unequal spacing using the “padding” idea is not going well for me. I am assuming I need to do something with GetItemAtIndex and then add to the previous some how, but I can’t seem to get there.

Any suggestions?

Thanks very much!







Hi Paul,

Have a look at the following discussions:

I’ll give those a try and let you know how I make out. Thanks.

Hi Dimitar: Thanks for those links. I used the second example and the List.Scan did the trick! Thanks so much.

1 Like

how can I do the same of List.Scan node with design script or other combination of math nodes?

I think there is a Node to Code item on the menu somewhere. That might tell you what you need. Otherwise, I don’t really know. I always use nodes. I don’t know how to write design script.

I had same question than you and I resolved it just now with another approach without python code or that scan node which impossible to convert to designscript code.

the solution you found @Paul_Aubin it is shorter script with few nodes, unfortunately Dynamo do not allow to convert to designscript code with the List.Scan node

same result other solutions with designscript code and list and math nodes:

To achieve want you wanted, just sum the span distance to this result, but first item of the list as 0.