I am busy with a dynamo script when I ran into an issue. I have a list of values and I need to add spacing values in between but this spacing value also needs to be added to the values. I have this list:
The values in this list above need to be come the valuse below. ( the logic here is: first value gets nothing, the second gets 3000, the third gets 6000 and so on.
An easy way of doing this is with a range and adding these values.
But it turns out you can do this as well with a few lines of python code
import clr Segments = IN StairCaseWidth = IN result =  for i,s in enumerate(Segments): temp = s + StairCaseWidth*i result.append(temp) OUT = result
The trick here, is ofcourse, the enumerate function. The first time the for loop starts the i = 0 which means that the variable temp gets the result of first segment + StairCaseWidth * 0 which gives 0.
The second time the loop starts, i = 1 which gives the 28000+3000.
The third time the loop starts, i = 2 which gives the 56000+6000
and so on