Variables and data types
Q1: How do I programmatically define a ModelCenter assembly in the component tree?
A1: Write nested variable names using ”.” separators:
- ModelCenter takes care of assembly creation automatically:\

- Then use the same name in the
RunAsyncmethod to access the nested variable:\
Q2: What characters are allowed for plugin variable names?
A2: PACZ variables use the same convention as Java variables, except dollar signs are not supported.- Essentially alphanumeric + underscore, but the first character must be either a letter or underscore
- Periods are only supported as the separator between different levels of a hierarchy
- Spaces, punctuation, and special characters are not allowed
Q3: How do I access value and default value from the runner context?
A3: Access both read-only values as follows:
- Accessing
DefaultValueis done with integer index rather than name. The user must search (using LINQ or a traditional iterator) through the available indices to find the desired name/DefaultValue. You are technically reading directly from the PACZ file created during the Builder context - Note that
Valuecan only be accessed from the Runner context. There is no access toValuefrom the Builder context - In the Builder context, only
DefaultValuecan be set, which is later copied to create the variable’sValue. This copy process is the responsibility of the host process, such as ModelCenter.
Q4: How do I create an array variable?
A4: Using a two-item Boolean array as an example:File and path handling
Q5: Is it possible to query relative path from inside the plugin?
A5: The plugin’smodel object is aware of both relative and absolute paths:

FilePath property changes depending on whether the path is inside or outside the extraction folder:

Variable management
Q6: How do I remove a single input/output variable from the model?
A6: Create a function like the following:_removeOutput(viewModel, "x2");

Q7: How do I define a file as an output variable?
A7: During output list construction you would have:Q8: How do I determine the type of an input variable at runtime?
Question: From the runner context, I can iterate through input variables usingforeach (var key in inputs.Keys). I need to determine whether each input is type string or type real. I currently have (StringValue)inputs[key].SafeValue. That crashes when it is a real. Is there a way to check what type of input it is?
A8: There are several ways, depending on your use case.
The simplest is to just use SafeValue.VaraibleType, which is an enumeration of all the possible types (Integer, Real, String, Boolean, File, IntegerArray, RealArray, StringArray, BooleanArray, FileArray).
You can also use the safe type conversion capabilities of C# such as inputs[key].SafeValue As StrinValue, which returns the converted value
or null if it is not the correct type.
Q9: How do I create a multi-dimensional array?
A9: Example using integers:Q10: How do I add a description to an IRuntimeVariable instance?
A10: See the x3 variable definition in the BasicPaczPlugin example.