Syntax in levels using code blocks

Hello,
is there a way to achieve the follow using just the code block?
Thanks

1 Like

The correct syntax for levels is <n> for the nth level list. I don’t think it works with the “shorthand” version of list[n] but you can use GetItemAtIndex to do the same thing: DSCore.List.GetItemAtIndex(list<2>,0);

1 Like

I also use Node 2 Code a lot to learn the syntax.

5 Likes

Tip:
Select the nodes you want to make a code block, right click the background, and select “node to code”.

2 Likes

1 Like

Thanks guys,
I was after a shorthand for this, but apparently there is no way to avoid the use of List.GetItemAtIndex.
Cheers.
Simone

Hey guys, quick taught on this : If I am right you want to get all the items at index zero for each list. A short hand for each one of them is Lst[listindex][objectindex] so :

Lst[0][0]
Lst[1][0]
Lst[2][0]
…

The 0, 1, 2… are basicly the list length right?

You could probably shorthand this with something like
L= 0…(len(lst)-1))
YourItems = Lst[L][0]

I on my phone can’t check if this works but design script usually accepts list of integer replacing integer value and just repeats the process.

If it does not work go in imperative mode with [imperative] in the code block and try a python–like script with a “for” loop based on a list of index.

All the best
P.

Here is DesignScript Language Specification 2.1, which includes reference about this topic in chapters 9 and 10