Indexing repeated items in a list


#1

In our office the room numbering is based on level, building segment and function.

I’ve already managed to create a list (List A) with all this information combined (derived from the room parameters) but now I need to add an index 01,02,03,… to this list.

If a certain number appears only once it List A, the added index should be 01, if there is a second item, this will get index 02, and so on. So each room has an unique number.

Could you help me find the correct nodes for this, or do I need custom nodes/scripts?

 

RenumberRooms_KHA

 


#2

Which list is considered “List A”


#3

To list I’ve managed to create so far. The resulting list after the last node “String From List”.

After each item I need to add an index: 01 for unique items or the first one when there’s duplicates, 02 for the second ones,…

Like you’ll see in the attached image, the resulting list needs to be:

[0] D.100.X.60.01

[1] D.100.X.60.02

[2] D.091.X.TS.01

[3] etc…


#4

File: Indexing.dyn


#5

I tried recreating you script, but is fails at the SortByKey node. The Flatten node at the top returns 6 values (in my test project), but the Flatten node at the Bottom return 14. The error message for SortByKey is “… isoverindexed” which makes sense, but I can’t seem to resolve this.

RenumberRooms_KHA


#6

Nvm, I found my mistake. I didn’t see the lacing in the List.Count Node.

Thanks for the script, works like a charm.


#7

I suspect the trouble is caused by the nodes you’ve added. Check if it works without them.

20160218-2

EDIT: Seems like this was resolved while I was typing this response.