# FromModelica Function

Use the FromModelica function to define parameter values of Activate Modelica components.

The FromModelica function gives you access to Modelica resources, which you can use to define the parameter values of Activate Modelica components. These resources include both data and functions available in Modelica libraries, and other Activate Modelica components present in the model.

## Syntax

FromModelica(path [,opt1 [, opt2]])

## Inputs

path
Designates either an entity in a Modelica library or a component in the model.
Type: string
opt1
Can be a string, representing a name, specifying an entity (an element of a record, an element of a package, a component parameter…), a struct, defining a modifier, or a cell containing the arguments of a function call. A struct is also used in case of function-calls with named arguments.
Type: string, struct | cell
opt2
Can be a string, representing a name, specifying an entity (an element of a record, an element of a package, a component parameter…), a struct, defining a modifier, or a cell containing the arguments of a function call. A struct is also used in case of function-calls with named arguments.
Type: string, struct | cell

## Examples

In case of Modelica library access, path is an OML string designating a library element following the usual Modelica syntax, where the hierarchy is specified using “dot” notation, with “Modelica” as root in case of MSL for example. The path can designate a constant, a record, a function, a package, etc.

Retrieve the value of the absolute zero temperature in Centigrade from the package Modelica Constants:
FromModelica(‘Modelica.Constants.T_zero’)
Retrieve a Modelica record where M330_50A is an element of Package Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter:
FromModelica('Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter.M330_50A')
Retrieve a Modelica record where the name of the record is provided as the second argument of the function:
FromModelica('Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter’,’M330_50A')
The name of the record can be parameterized using an OML variable. In the following example, rec is an OML string defined in the workspace of the diagram containing the component, specifying the record selected in the package:
FromModelica('Modelica.Magnetic.FluxTubes.Material.HysteresisEverettParameter’, rec)

For example, rec can be conditionally defined in the diagram context as:

if cond, rec=’M330_50A’, else rec=’M270_50A’; end
The optional arguments can also be used to define modifiers. The structure field names correspond to the modified entity names, for example for modifying record elements, as shown in the following example:
FromModelica('Modelica.Magnetic.FundamentalWave.Types','SalientReluctance',struct('d',12, 'q',14))
The modifier above is specified by an optional argument of type OML structure. The argument struct(‘d’,12,’q’,14) corresponds to the Modelica modification (q=12, q=14). Note that the new values of d and q record elements can be parameterized using OML expressions.

Function calls in Modelica can be done both with and without named arguments. Named arguments can be considered specific modifiers and can be specified using OML as indicated previously. The positional argument passing is supported using a cell instead of a struct.

The following example shows how the symmetricOrientation function can be used with argument m=3:
FromModelica('Modelica.Electrical.MultiPhase.Functions.symmetricOrientation’,struct(‘m’,3))
Alternatively, since m is the first (and unique) argument of the symmetricOrientation function, the same result is obtained by the following example:
FromModelica('Modelica.Electrical.MultiPhase.Functions.symmetricOrientation’, {3})
If the function has multiple arguments, the cell includes all the arguments in order:
FromModelica('Modelica.Electrical.MultiPhase.Functions.activePower’, {v,i})