LunchBox Mass Addition

As I said on the previous topic…

List.Map is a way to apply a function over a set of inputs. It was more common before list levels and isn’t necessary for this use case anymore. This is also only being used here because your list structure is different - a list of lists instead of a single list like you originally showed.

The python output is not a function and won’t work with List.Map in this way. You could use a function (the code block solution I gave would likely accomplish this) and List.Map but it’s really a better idea to adapt these old examples and graphs to the newer methods we have available.

I would suggest modifying the python code to allow for the extra list level via another loop or using those nodes from the code block solution and the appropriate list levels for your list structure.

Look into looping inputs with Python. There are plenty of topics that already cover this in the forums.

The issue is that the current code is set to work on a single list, but you have a list of sublists. So now you need to loop through each sublist before summing the values.

Try some of the suggestions above before asking for help on how exactly to do it.

1 Like

See my response here:
https://forum.dynamobim.com/t/dynamo-revit-revit-and-space-planning-lunchbox-mass-addition-fails/81266

1 Like

Adding from our DM discussion so others can reference:

def cumsum(lst):
	result = []
	m = 0
	for n in lst:
		m = m+n
		result.append(m)
	return result

OUT = [cumsum(l) for l in IN[0]]

2 Likes

@kyle_martin_Gensler @Nick_Boyts @GavinCrump @jacob.small

Super to learn from you guys, problem solved!


Fig. 1


Fig. 2


Fig. 3

3 Likes