Creating a number sequence for each index of a list?


#1

Hi,

I’m producing a script for populating the door mark parameter in various ways depending on the type of door in a project. I’d like some items we’re scheduling with the doors, such as notice boards and lift doors, to be scheduled as “text parameter” “00n” with n being an increasing number. I want the 00n sequence to start again for each type of element for example: Lift doors 001, Lift doors 002. Notice Board 001, Notice board 002, Notice Board 003.

At the moment I’ve managed to list them all consecutively: Lift doors 001, Lift doors 002, Notice Board 003 etc. but don’t know how to restart the sequence for each type. I’ve created a list with each type at a different index number but I don’t want to split it via specific index number because different projects could have different numbers of types. I’ve attached an image which hopefully clarifies this a little.

Thanks in advance,

Kieran


#2


#3

Hi,

Thanks for the help so far, that has simplified the approach I was taking to generate the names. I’ve attached an image showing how this applies to my project, I’d like to be able to now produce names with the format: Notice Board 001 , Notice Board 002, Lift Doors 001. So the sequence restarts when the type of element changes.

Many thanks for your help so far,

Kieran


#4

@K.Marsh

Kieran,

Combine List.GroupByKey with this


#5

Maybe this:


#6

That’s great thanks! Would you mind explaining that first Code Block for future reference?


#8

Have a look here under “How about lacing”: http://dynamoprimer.com/en/07_Code-Block/7-2_Design-Script-syntax.html