How do you use list levels in a code block?

Hi All,

Using the get item at index can get a bit bulky, so I often use code blocks. However, I can’t seem to get code blocks to replicate the levels function of the List.GetItemAtIndex node (see image).

Do any of you know the syntax for selecting items of a list at levels?

image

2 Likes

Select the List.GetItemAtIndex node and the code block feeding into it, then right click the backround and choose ‘node to code.’

Hi Jacob,

Thanks for the tip, but creating a code block for List.GetItemAtIndex isn’t quite what I’m trying to do. I want to use the dynamo syntax for selecting an item at an index in the form I showed earlier “X[1]”, but I want to select the items at levels.

I’ve tried using the replicator guides as they’re used within the List.GetItemAtIndex Code Block, but I can’t get the syntax right.

image

List.GetItemAtIndex(lst<1>,1);

getItm

12 Likes

As far as I know, that syntax doesn’t support levels - you’d have to use two sets of bracket values to even pull the value from the list.

x[0][1];

Try using first with a range 0…4, and the second with a single value.

x[0..4][1];

Due to the complexity of n dimensional lists, the method I lead you to before is preferred.

List.GetItemAtIndex(lst@L2<1>,1);

Otherwise you need to program a way to catch a situation where you have a list that is five levels deep. Or four levels deep. Or n. Or if your list is 6 items long instead of 5. Or 3 items long… you get the idea.

6 Likes

you save me all the time … thanx

1 Like