To get the meaning of this syntax

{'m1':self.props.selection.data[0].MachineName}
i want to know the meaning of the [0] , because i want to pass parameters to named query but it says i have given too many parameters

Presumably you could select multiple items, Ignition will then give this as a list of selected items. [0] will give you the first item, [1] will give the second item etc.

If you only select 1 item it will just have this first selection at [0]

[0] means that you are accessing an element of an array (technically a list in python) at index 0. That means that (in the snippet) data is an array(list), at index 0 it has an object, and that object has a property named MachineName. The value of that property is the value assigned to the 'm1' key in the dictionary shown in the snippet.

Where is this snippet from? If your problem is with passing too many parameters to a named query, then I wouldn't expect "[0]" to be your problem. Post more of your code with more context and we might be able to help you.

1 Like