While Loop | I want loop to output a list, but its outputting "Empty Dictionary"

Hello,

Please assist with the following:

I have a list of viewport widths (coincidentally the same value here) which I would like to sum one-by-one until it exceeds the max x-coordinate of my sheet.

While%20Loop
I would like the results of:
xList[0] + xList[1]
xList[1] + xList[2]
xList[i] + …

to be output as a list as I intend to use these values to move different viewports up by the iterated distances once I get the loop to work, but currently its giving me an output “Empty Dictionary”

Regards,
Connor

Like this?

while (viewportW < SheetUMaxX) doesn’t work because viewportW is a list. You need to have a single value to compare which is provided here by currentWidth which is added to with each iteration.

viewportW;
sheetUMaxX = 413.5;

[Imperative]
{
	xList = {};
	i = 0;
	currentWidth = 0;
	while (currentWidth < sheetUMaxX)
		{
		currentWidth = currentWidth + viewportW[i];
		xList[i] = currentWidth;
		i = i + 1;
		}
	return xList;
};

You can achieve this in nodes as well…albeit in a slightly more convoluted way.

Hope this helps,
Thomas

3 Likes

Ah okay. I was trying to input a list because I want a list out - however I see why I would need to separate it into single values.

I should of shared my .dyn. Thank you for all your effort - it will help a ton!

1 Like