Replace list item by adding a number to the sum of previous numbers

Hi everyone,

I’m trying to create a list of floor elevations for a 20 storied tower.
Most of the floors a typical height (15’), but there is one in the middle and two on the top which need to be higher (25’). I tried to generate 20 equal floors with Series and then replace list items for those three floors with different number for heights.
But, obviously these inserted new heights need to be added to the proceeding heights in the list to get the elevation number.
Could there be a short/elegant way to achieve that?
Please see the attached script and a clip below
3034 1106_Floor elevations.gh (10.8 KB)
:

edited:
I pulled the trigger so quick in there, i figured that the values after index 10 will also change after the additional 10 ft from the original value.

idk how to do it in vanilla grasshopper but i thought i’ll just post this anyway for visibility

all_floors = []

start = 25
current_value = start

for i in range(len(floors)):
    if i != 0:
        if i in indices:
            current_value += new_value
        elif 11 <= i <= 17:
            current_value += original_value
        else:
            current_value += original_value
    all_floors.append(current_value)

Mass addition:
3034 1106_Floor elevations 2.gh (12.9 KB)

Thank you very much guys.

Bruce,
Looks like I was on the right path overall, but had to replace items first and only then do mass addition.

Great!

1 Like