This is a documentation error. Accessing labels using an index number is not supported. If there is a reason you aren't able to access the labels by name, you can get the labels by index if you first get the labels node.
The following code will get you what you want:
current.attrs.labels.subnodes[1].value = 2;
attrs gives you access to all of the object's attributes (when looking in the tree, the nodes with blue names). Then you get the labels node, and access the subnodes of label which is an array. I hope this helps!
Thank you very much.
There is another error in the manual:
@Li ze, Maybe you open another question, because the documentation is wrong there, too. It is much easier to find an answer in a question than in a comment. Many thanks!
@Matt Long, @phil.bobo, it seems that the sub class “labels” and the attribute “labels” are misleading a bit, aren’t they? Perhaps the progress in development of this sub class stopped too early?
Object.labels.assert(..) vs. Object.attrs.labels.
Process flow uses the same code for accessing token labels as the object accesses its labels. Since tokens are allowed to have parent labels, and parent of parent labels etc, it didn't make sense to access labels by rank. We decided not to implement that as an option. There also isn't any real advantage to accessing by index rather than by name. If you're accessing data by index you might as well use a label table.
@Matt Long, thank you for pointing to the connection with tokens. Sometimes I forget to look at the whole world of FlexSim.
What is it you're trying to accomplish with the label index? If you're trying to set a label, I suggest using a trigger. That way, you can specify the exact label and what value you want to set it to be.
14 People are following this question.
FlexSim can help you understand and improve any system or process. Transform your existing data into accurate predictions.
FlexSim is a fully 3D simulation software environment. FlexSim can be used to simulate any process in any industry.
FlexSim®, FlexSim Healthcare™, Problem Solved.®, the FlexSim logo, the FlexSim X-mark, and the FlexSim Healthcare logo with stylized Caduceus mark are trademarks of FlexSim Software Products, Inc. All rights reserved.
Privacy | Do not sell or share my personal information | Cookie preferences | Report noncompliance | Terms of use | Legal | © Autodesk Inc. All rights reserved