Create and assign values to child labels via flexscript

Create and assign values to child labels via flexscript

christopher_h4
Not applicable
214 Views
6 Replies
Message 1 of 7

Create and assign values to child labels via flexscript

christopher_h4
Not applicable

[ FlexSim 20.2.3 ]

I'm currently creating a model in which I want to record some simulation results as label data. However, to distinguish between model setup labels and results data labels I wanted to create a label called "results" and then assign nodes within "results" to the different values.

39101-1620059784057.png

Is there some way to do this, preferably via coding (Flexscript or C++)?

0 Likes
Accepted solutions (1)
215 Views
6 Replies
Replies (6)
Message 2 of 7

jason_lightfootVL7B4
Autodesk
Autodesk

You can use tables or arrays as labels.

Message 3 of 7

Jeanette_Fullmer
Community Manager
Community Manager

Hi @Christopher H4, was jason.lightfoot's answer helpful? If so, please click the red "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always unaccept and comment back to reopen your question.

0 Likes
Message 4 of 7

christopher_h4
Not applicable
Accepted solution

I managed to figure out this issue on my own.

If anyone has this same issue the following is the code I used.

Model.find("TaskExecuter").labels.assert("results");

Model.find("TaskExecuter").labels["results"].subnodes.assert(sig_out_channel);

Model.find("TaskExecuter").labels["results"].subnodes[sig_out_channel].value = Result_Data;


The trick was having to have subnodes predefined as nodes with subnodes cannot be dynamically created and allocated as normal nodes can.

0 Likes
Message 5 of 7

christopher_h4
Not applicable

How do you unaccept the answer? I see no option to do so.

0 Likes
Message 6 of 7

joerg_vogel_HsH
Mentor
Mentor

Hi @Christopher H4, can you append a code line, which you have tried and didn’t work, because we can see what works, but not what doesn’t? Many thanks.

0 Likes
Message 7 of 7

christopher_h4
Not applicable

I tried a few different things some of which I thought should work and some hail mary's that didn't really have a leg to stand on but my work based off syntax of other things.

The big one I was surprised about was...

Model.find("TaskExecuter").labels["results"].value = Result_Data;<---- this works

Model.find("TaskExecuter").labels["results"].subnodes[sig_out_channel].value = Result_Data; <--But this doesn't (sig_out_channel is a string type variable that is defined elsewhere so quotes are not the issue)

FlexSim seems to create label nodes on the fly if a value is assigned to a new variable. subnodes on label nodes are not created on the fly when data is assigned.