Index is outside the given range

Hi,
I am trying to call specific elements from a list.
The DSCore.List.FirstItem works, but list[0] does not work.
However, any list that I define in a code block is getting picked up correctly.
Not sure what I am doing wrong here.
Please suggest.

  • Thanksindexing error

Can you show where the t55 input is coming from and what the error in the codeblock is? Could be that t55 is actually a dictionary (or something similar) and not a list.

Edit: Although I don’t know why FirstItem would still work… Still worth showing us the input.

All the errors are the same “Warning: The index is outside the given range”.
This is the input:
1 input
I switched off and on different index based calls and here are the results:
2 input
3 input

As you can see list defined in the code block works alright but lists coming in from the watch node doesn’t

Yup. The issue is because FilterByBoolMask returns something like a dictionary - it’s not a list of values but a set of lists. Can’t remember if there’s a way to separate the values when using code blocks, but there was a similar thread on the forums a while ago. I’ll see if I can find it.

Here we go: Filter by Bool Mask

1 Like

Thanks for the prompt reply.
So the output is not a list.

Is the indexing syntax of a dictionary different from that of a list ?
I don’t actually understand what a dictionary is.

On the post that you linked, people are using some [“in”] and [“out”], I am not familiar with that syntax either.
Are these somehow related?

These might be pretty basic questions because I am not a programmer.

If you use a list.filterbyboolmask node and convert it to designscript you will see that the node actually has three outputs in designscript. The first of which is what you are using. The second gets the included from the nested dictionary. The third gets the excluded from the nested dictionary. Try that out and review the link as well as the dynamo primer and design script language guide for additional info.

@adi

In the Ampersand package there is a list to dictionary node.

Marcel

As stated the output is a dictionary. The keys are “in” and “out” like the output ports on the FilterByBooleanMask node.

2 Likes

Like @jostein_olsen mentioned, the keys are the outputs from the dictionary. In the case of FilterByBoolMask, “in” and “out”.
image

A dictionary is a pair of lists that uses one input (key) to “lookup” an output (value).

1 Like

@jacob.small
Hi,
I come from a minimal MATLAB background. Like DesignScript it has function autocomplete feature. Is there a documentation of all the functions too somewhere. Because some functions are within other functions like LIst.UniqueItems or Manage.RemoveNulls. Unless I know that there is a Manage thing before removenulls I would not know that there is a removenulls hidden within it.
Autodesk has a website for their API and all the functions in it. Looking for something similar for designscript.

You can see these links:
http://dynamoprimer.com/en/07_Code-Block/7-2_Design-Script-syntax.html
http://dynamobim.org/help-center/

2 Likes

You can also select a group of nodes and right-click (off the node) and select Node to Code to convert a set of nodes to their DesignScript equivalent. Helpful for learning the function calls.