question

Stan Davis avatar image
0 Likes"
Stan Davis asked Ryan Clark commented

Get Variable Shared Asset Value in Code

For a Process Flow Variable, I can get its value using getprocessflowvar(processFlow, "pfVar")

But I'm struggling with getting a Variable shared asset's current value using flexscript.

Some of what I've tried...

getvarnum(processFlow, "MyVar")

Model.find("MyVar").value

getstat(getactivity(processFlow, "MyVar"), "Content", STAT_CURRENT)


Any help would be appreciated. Thanks

FlexSim 21.1.5
processflowflexscriptvariableflexsim 21.1.5
· 1
5 |100000

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

Ryan Clark avatar image Ryan Clark commented ·

Hi @stan.davis, was Felix Möhlmann'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 ·

1 Answer

Felix Möhlmann avatar image
1 Like"
Felix Möhlmann answered Stan Davis commented
Variant value = processFlow.find("MyVar>variables/variableRef").evaluate();

I don't know if this is the "proper" way to access it (probably not), but it should work.

· 5
5 |100000

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

Stan Davis avatar image Stan Davis commented ·
Unfortunately that just returns the Variable's 'initial' value as set in the 'Variable or Value' property. It does not return the Variables current value.
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Stan Davis commented ·

You're right. I only tested it when the variable was set to reference an object's stats, sorry for that.

Try this instead:

Variant value = getsdtvalue(processFlow.find("MyVar>stats/instances/ProcessFlow"), "currentValue");

Variable_In_Code.fsm

0 Likes 0 ·
Stan Davis avatar image Stan Davis Felix Möhlmann commented ·

I appreciate the help. However, that's still not working for me. I'm also getting errors with your attached model...

1630603177410.png

0 Likes 0 ·
1630603177410.png (34.2 KiB)
Show more comments