Processing points in a list into a new list

I’ve created a grid of rectangular surfaces that are cut by the edges of a roof, so now basically the panels are within the roof and the ones at the edge have the appropriate shape. Of these panels I have the corner points: a list of panels for each roof, and within that a sublist with the points of each panel. The amount of points can be three, four, five, basically anything up to eight. So I’ve made an eight point adaptive family.

What I want to do is make a function to create a new list with the same structure, except each sublist now has eight rows: the first two corresponding with the first two points, and the rest of the adaptive family points divided over the remainders of the points (so three to eight are corresponding with point three of a three point panel, 3 to 5 with point three and 6 to 8 with point four of a fourpount panel etc… I use a division and a Math.Round operation for this).

The basic idea is as follows:


for(sublists in list)
for(points in sublists)
#make eight new entries filled with the appropriate points

Except… when I make a function and input the list, what it returns even if I do nothing is an empty list with the same structure. I find it very difficult to make a new list, matching the input list, to do these operations in. I could basically create a list within the function with only the index [0], but then the node calling the function says that the list is over-indexed.

Does anyone have an idea how to do this best? So far, lists confuse me. Any help would be greatly appreciated.

Hello Bram Weinreder,

I have gone through your description but I don’t think I understand fully and don’t want to give any wrong solution to you.

Is it possible for you to create the structure of list what you want in Paint and show me what exactly you want.

Or you could share your file as well.



I will post something tomorrow. It is not hard though… I have generated a list of panels with different shapes and sizes, then queried the start points of all their edges (which are automatically in sub lists). They have three to about six points each, and I want to make all sub lists 8 points long and create duplicate points where needed, in order to place the panels in my model as 8-point adaptive components.

This is what I was talking about (& how I ended up doing it… surprisingly easy).



Nice result! Could you please explain what [Imperative] means? I follow all else :slight_smile:

You can’t use If-statements or for/while loops in basic designscript, unless you use one of the prebuilt nodes. If you want to use them in a script, you need to use an Imperative codeblock. Why it’s called that way beats me but it has become my bread and butter.


Ah cool, that sheds a little light on the situation :slight_smile: Many thanks!