question

Christopher H4 avatar image
0 Likes"
Christopher H4 asked Christopher H4 edited

Create and assign values to child labels via flexscript

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.

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

FlexSim 20.2.3
labelsflexsim 20.2.3
1620059784057.png (13.1 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jeanette F avatar image Jeanette F ♦♦ commented ·

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 0 ·
Christopher H4 avatar image Christopher H4 Jeanette F ♦♦ commented ·

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

0 Likes 0 ·
Christopher H4 avatar image
0 Likes"
Christopher H4 answered Christopher H4 edited

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.


1621026500423.png (12.7 KiB)
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joerg Vogel avatar image Joerg Vogel commented ·

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 0 ·
Christopher H4 avatar image Christopher H4 Joerg Vogel commented ·

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.

1 Like 1 ·
Jason Lightfoot avatar image
1 Like"
Jason Lightfoot answered

You can use tables or arrays as labels.

5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.