List to Index

Hi, this is my first post, and I appreciate any help I can get.
I have 2 lists that I would like to combine, and I want the values in the first lists to become indices. So, looking at the attached, I would like a list that had 32 individual indices of 850, then 32 indices of 350, etc.
Is there a way to do that?

Hi @case.devisser

Welcome to Dynamo Community!

List.OfRepeatedItem should get you what you want.

1 Like

@Andreas_Dieckmann Is this what he needs?

I think he wants to repeat each room area by the corresponding room quantities. So the room area would go into the item input and the room quantity into the amount input.

1 Like

Thanks for the quick replies! I think we’re getting close, but the problem I’m running into is that List.OfRepeatedItem doesn’t seem to take an array for the amount input. What @Andreas_Dieckmann said is correct. I’d like “Room Quantities” to define the amount of the correlating “Room Areas”. In @Kulkul’s example, it’s feeding a single number, which is close, but doesn’t correlate .

When I try adding Room Quantities to the Amount input, it gives me this error.

I’d like something that looks like this:

List
| :arrow_down_small: 0 List
| | 0 850
…(32 times)
| | 32 850
| :arrow_down_small: 1 List
| | 0 350
…(32 times)
| | 32 350
| :arrow_down_small: 2 List
| | 0 50
…(32 times)
| | 32 50
| :arrow_down_small: 3 List
| | 0 25
…(32 times)
| | 32 25
| :arrow_down_small: 4 List
| | 0 400
…(5 times)
| | 5 400
| :arrow_down_small: 5 List
| | 0 400
| :arrow_down_small: 6 List
| | 0 100
| | 1 100

@case.devisser Right Click "Change Lacing to longest" for “List.ofRepeatedItem” node:
image

@Kulkul It still gives me the same error when I set Lacing to Longest. Same with cross-product. Your output is exactly what I’m going for though.

Not sure if the list type has anything to do with it, but my inputs are List.GetItemAtIndex nodes. They’re extracting the numbers from an excel file up the line.

Add “Object.Type” to “Room.Quantities” and “Room.Areas” and show us what does it says.

image

You need to convert strings to numbers. Add “String.ToNumber” node to both and then use “List.OfRepeatedItems”.

1 Like

That worked! Thanks for all the help!!

Glad it worked!

1 Like