From {L01, L03, L04, L05, L07} To {L01, L03-L05, L07}

Hello Dynamo community,

From {L01, L03, L04, L05, L07} To {L01, L03-L05, L07}

I am trying to figure out how could I convert a list with all the levels where a furniture type are to a more reduced list ommiting consecutive levels.

I want to convert a list with a lot of values to a shorter one with the first and the last value of the different secuences that are in the list. Finally the idea would be to convert this values to strings with a dash betwen the first and last value of each secuence to finally be added to a parameter in the family type and show the location of each type in the schedule.

Please let me know if I could clarify more my issue and thanks in advance!

Bests,
Sergio

Could you share a picture of what you’ve tried so far? Will help to clarify further what you’re trying to do as well :slight_smile:

1 Like

You could use list indexing together with something like the “Flatten” command:

{x[0], Flatten(x[1…3]), x[4]};

Then proceed with a String.Join node (or two) :

An example of your list structure would help clear things up

1 Like

@Sergio or something like this?
20171026-1

2 Likes

It would indeed be clearer with a something like a schema and an illustration of what you tried so far with Dynamo :slightly_smiling_face:

1 Like

Hello guys,

Thanks for the comments @awilliams @Dimitar_Venkov. Find attached a couple of images to clarify the issue in question.
Looking forwards to your answers.

Regards,
Sergio

1 Like

And @Vikram_Subbaiah and @Yna_Db, folloowing the schedule that I have with the previous Dynamo script and on the bottom the two possible ways to explain the location of the furniture that I would like to achieve.

If I get it well, you want to gather levels names where a type of furniture is present and create a parameter value by concatenating the first and last of these names?

Exactly, I want to simplyfiy my schedule to show where each type of furniture is in a more reduced way.

What I can’t figure out is how to chop a flatten list with all the levels where the family type is.

I though of a kind of conditional value in the select node to pick up and elements if the Index value [n-1] has == to the index value [n] + 1. Maybe I could chop the list in this cases to then pick up the first and the last value.

Once you have your levels filtered down to integers you can group consecutive values together. Then you just need to do a little IF magic to get your levels to single values or paired mins and maxes.

1 Like

Thanks so much @Nick_Boyts, I’ll read more about GetKeys and List.GroupByKey to understand how they work, Also let’s see if I figure out the magic node. But this is a great advance!