global variables in Diagram Context

andyer
andyer
Altair Employee
edited October 2020 in Community Q&A

Hello Activate enthusiasts!

 

Does Activate support global variables in Diagram contexts (OML)?   I see cases where it works (constant sources) and where it doesn't (MathExpressions/MatrixExpressions) from my testing (attached is an example).  Just wondering if it is supposed to work or not :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />

e.g.,: Define in the Diagram context:

global var_a var_b var_c

 

Use var_a, var_b, var_c as parameters in the blocks within the superblocks.

 

I'd like to define a set of variables in a SuperBlock context and then use those same variables in another SuperBlock context to keep the variables encapsulated in the two superblocks and only define the variables in one place to make it easier to use.  (For example, define Vehicle data in only one place instead of multiple places).   What I would like to do is somewhat analogous to SignalScoping, but for constant (variable) values in the Diagram Context.

 

The workaround is to define the variables one level up, then all children get these variables.  But then the variables aren't defined locally to the superblock which I like to keep the data organized.   I guess this is fine, just wondering if I might be able to use global variables to make this work.    Other ideas are welcome, too :)/emoticons/default_smile.png' srcset='/emoticons/smile@2x.png 2x' title=':)' width='20' />

 

Thanks,

 

Andy

Unable to find an attachment - read this blog