Chop List by index

Hello,

I’m currently working on a furniture family library that should place all types of my families in order to find some bugs in my families. I wrote a script that loads my families, sorts them into categories (seating, tables, lighting, …) via a text parameter they have.

I use the placeInstance.byCoordinate node, so i have coordinates in X,Y and Z direction, Z are different categories as layers, Y are the different families and in X direction all the types of the families should be placed. I figured most of it out somehow.

Now I have a node that has a list of all family types of one cateory and I got a node with a list of indexs which tells me where each family starts, like this:

List1: 0 Table1Type1, 1 Table1Type2, 2 Table1Type3, 3 Table2Type1, 4 Table3Type1, 5 Table3Type2
List2: 0, 3, 4

Does anybody know how I can chop my lists with the help of these indices? There is no way to do it manually with over 300 families and over 800 types…

Thank you!

Hi, @vanessa.welsch!

Can you share excel and dyn files? I’ve done similar task some time ago.

1 Like

Hi @Vladimir ,
Sadly I’m not allowed to share the Dynamo file due to company restrictions.
But here is a screenshot with the data:

image

1 Like

Hello, if it can help


python script

tab=IN[0]
last_index=IN[1]
chop=[]
for i in range(0,len(tab)-1):
    a=tab[i+1]-tab[i]
    chop.append(a)
chop.append(last_index)
OUT = chop

Cordially
christian.stan

This could work. I guess we would have to modify the first part as the name of my families are not numbered as in the first example I gave.
How would I count them then? :thinking:

maybe:
chop.dyn (18.6 KB)

and one more:
chop2.dyn (22.2 KB)

2 Likes

maybe this way

cordially
christian.stan

1 Like

Thank you!
I tried it with my data and it works perfectly!
I’ll make a custom node out of it and add it to my script. :smiley:

@vanessa.welsch, compare my 2 versions, there’s differences at the end of list!

All credits of chop goes to Spring’s node ꟿ List.Subpairs :slight_smile:

1 Like

Thank you!
Both scripts give me the exact same list at the end :smiley:

@christian.stan Thank you too! I appreciate your effort. :smiley: Sadly I wasn’t able to recreate your script as I need the data type “family type” at the end. Your script works well for strings though.

1 Like

The script also returns the family and family type, but it doesn’t matter, the main thing is to have your goal (the means are like the roads to Rome)
I did a training exercise. (good for progress :wink:)
Have a good day
Cordially
christian.stan

1 Like