Each of the Element Parameters has a reference to an object called a ParameterDefinition. A ParameterDefinition is associated with the model for the object and describes the attributes of the parameters that will be associated with elements representing that model. So each model includes an array of parameter definitions that act like templates for creating the parameters associated with an Element representing the model. To get information about the type of the Parameter object we need to look at the ParameterDefinition or template from which it was created. For example lets create a script that adds a schematic, adds a MLIN element to that schematic and then prints some information about the parameters for that element.
If we run this program we get the following output:
ID = TL1 Data Type = 4 W = 20 Data Type = 0 L = 200 Data Type = 0 MSUB = Data Type = 5
While this is useful in that it provides values for the data type it would be nicer if we had some enumerations. In the object browser we can see that the ParameterDefinition.DataType is a property of type mwParamDefDataType which has the following definition.
Also if we place a "." after the DataType property then it will give us a list of the possible values as shown in Figure 11.
This can be very useful if we are trying to control flow based on some specific data type, like printing only double values, however in our case we want to print the data type so I'll create a mapping function to map from the type value to a string. A quick mapping function might look like this:
And then we can use this in the main body of the code:
Which now produces the following output:
ID = TL1 Data Type = mwPDDT_ElementName W = 20 Data Type = mwPDDT_Real L = 200 Data Type = mwPDDT_Real MSUB = Data Type = mwPDDT_DataModel
So the detailed type information about a parameter is available from the ParameterDefinition which acts as a template to create the parameter when the Element is created and the parameter object includes a reference back to it's ParameterDefinition object.