Getting Index Number of List

How does one output the index numbers of multiple lists as a value and reapply those numbers back to parameters of elements within those lists? I have a list structure with three layers of lists. the last layer being a sublist of an X number of elements.



Thank You

List.count + setparametervalue?

The LIst.Count node only gives the number of items in a list. I need the index number. Also when I try to put it in to a setparametervalue node the result comes back as null.

Indices are just the zero-based sequence of a list. List.Count tells you how many items in the list and therefor how many indices you have. You just need to create the sequence.

Can you explain in more detail what it is you’re trying to do exactly? I’m guessing there’s better way to do this.

I have a list(could be multiple lists) containing an undefined number of sublists. Those undefined number of sublists have an undefined number of sublists which are lists made up of revit elements

I need the index numbers of the various levels of lists to use as values to input in to parameters within my revit elements that are within those lists.

First Level of lists: List of Panels(undefined). Index number for Panels should be 1,2

2nd Level of Lists: List of boards within the panel that host a max of 8 places for the revit element configurations. So 1 configuration takes up 1 slot. This list of boards is usually up to 3 but I would like to leave it undefined.

3rd Level of Lists: Lists of revit element configuration in each Board. I have managed to get the index number of these lists.

So for example. one parameter needs the the index number of the board within the panels. I need to feed that number in to all the elements within that list.

Let me know if I made any sense here lol

List.Count set the appropriate level, and feed that into a code block with 1..count. (or 0…count-1 if you want 0 based array indexing).

That’s a much more complicated scenario. Dealing with an undefined list structure is going to make things very difficult. If you have a reasonable cap that will simplify things by quite a bit, otherwise you’d probably have to use a recursive function.

How are you getting this structure in the first place? It seems like it would make more sense to work your logic in where you’re defining the list.

Ok so I managed to to get the numbers I wanted (things went in a different direction since this morning). Now all I need to do is add it in to all the elements within lists they correspond to. Please see below:

I have tried to use the setparametervalue node but I keep getting null values. I try to go to another level but it gives me wonky numbers. Did I set this up wrong?

I’m on the outside looking in, but I am fairly confident this would be better managed as a dictionary.

1 Like

Your list structure is probably too complicated to work with just list levels or lacing. You might be better off using python or duplicating your values for every item in the sublist so that everything matches structure-wise.

EDIT: It also could be an issue with your nulls in the values list. Are you wanting to write values back to the top level items that show null? It seems like you’re trying to do everything with one list while not actually applying all the same logic to every part of the list. That’s really going to make things confusing and complicated.