Important:  This page describes the previous method of using the MapleSim Model component directly through the DocumentTools[SetProperty] / [GetProperty] commands. This method has been deprecated and is not recommended.

You must now use the LinkModel command. For a complete description of this procedure, see MapleSim Application Programming Interface Overview.

To use the MapleSim Model component:

Note:  You can open one .msim file in the component at a time.

You can then use the commands in the DocumentTools package to view and change values associated with a model. For example, by using the GetProperty, SetProperty, and Do commands, you can retrieve a list of components in a MapleSim model and set parameter values. See the examples below for a full description.

Once you have opened your model in the MapleSim Model component you can browse your model by using the navigation tools at the top of the MapleSim Model component.

 • You can click Main to view the top level of your model, or use the drop-down menus to select a component or subsystem name.
 • You can open a MapleSim window to view your changes as you edit your model programmatically in Maple. To view your changes in MapleSim, right-click (Control-click for Macintosh®) the MapleSim Model component and select Open in MapleSim. The changes that you make in the Maple worksheet appear in the model displayed in MapleSim at the same time.
 • To save a model that you modified using the MapleSim Model component, you can either save the changes as part of the .mw file in Maple or as part of the .msim file in MapleSim. To save your changes in MapleSim, right-click (Control-click for Macintosh) the MapleSim Model component, select Open in MapleSim, and then save the model in MapleSim.
 • All parameter names that you retrieve using calls to DocumentTools are displayed in Modelica® or equivalent programmatic names; these names may differ from the names displayed for those parameters in the MapleSim interface. For example, if an Inertia component is included in a model, the angular velocity parameter is displayed as ${\mathrm{ω}}_{0}$ in the MapleSim interface and w_start in a Maple worksheet. You must also use the Modelica or equivalent programmatic name when you set parameter values by using calls to DocumentTools. For more information about how the parameter names are mapped to programmatic names, see the MapleSim Library Reference Guide in the MapleSim help system.

 Component Palette Image

 • The following table describes the control and use of the MapleSim Model component options.
 An x in the G column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
 An x in the S column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.

Option          G  S  Option Type

activecomponent x     string
components      x     string
parameters      x     string
simopts         x     string
system          x     string
#content        x     string
#parameters     x     string
#type           x     string
#value          x  x  string

 activecomponent
 Retrieves the name of the subsystem or modeling component that is currently displayed in the MapleSim Model component. To display a subsystem or modeling component in the MapleSim Model component, use the navigation controls to browse to the subsystem or modeling component that you want to view.
 components
 Retrieves a list of components and subsystems at all hierarchical levels of your model, including components within subsystems.
 parameters
 Retrieves a list of parameters at all hierarchical levels of your model, including parameters of components within subsystems.
 simopts
 Retrieves a list of simulation options that were set in the MapleSim interface and saved as part of the model. For more information about the simulation options, see MapleSim[RunSimulation](deprecated).
 system
 Retrieves a Maple record that displays the parameter values, modeling components, connection ports, probes, and connection lines associated with your complete model. The output is displayed in Modelica or equivalent source code.
 #content
 Retrieves a Maple record that displays the parameter values, modeling components, connection ports, probes, connection lines, and other information associated with a modeling component or subsystem. The output is displayed in Modelica or equivalent source code. This option takes the form #content, where  represents the name of the modeling component or subsystem for which you want to view content.
 #parameters
 Retrieves a list of parameter names available in a subsystem or component. This option takes the form #parameters, where  represents the name of the modeling component or subsystem for which you want to view parameter names.
 #type
 Retrieves a Maple record that displays the following information about a subsystem or component.
 • class - name of the subsystem or component definition to which the subsystem or component is linked.
 • instance - name of the shared subsystem or component. If you added multiple copies of a subsystem to your model, each shared subsystem will have a name that is distinct from its subsystem definition name. For example, when you create a subsystem called DC Motor, the class name may be DC Motor and copies of that subsystem may be called DC Motor 1, DC Motor 2, and so on.
 • isconnector - Boolean value that indicates whether the component is a connector.
 • isprotected - Boolean value that specifies whether the component is accessible from the top level of the model.
 This option takes the form #type, where  represents the name of the modeling component or subsystem for which you want to view type information.
 #value
 Retrieves or sets the values of parameters in your model. This option takes the form #value, where  represents the name of the modeling component or subsystem for which you want to retrieve or set parameter values.

Examples

In these examples, the MapleSim Model component name is Simulation0. For demonstration purposes, these examples use the Sliding Table example that is included with your MapleSim installation.

Example 1 - View and set parameters of a MapleSim model programmatically.

 1 Open a new Maple worksheet.
 2 From the Components palette, click MapleSim component   to insert a MapleSim Model component.
 3 Right-click (Control-click for Macintosh) the MapleSim Model component and select Component Properties.
 4 Click Select...
 5 Browse to the /toolbox/MapleSim/data/examples directory (where is the directory in which Maple is installed) and open the FrictionlessSlidingTable.msim example.
 6 In the Simulation Properties dialog box, click OK. The model is opened in the MapleSim Model component.
 7 At a Maple prompt below the MapleSim Model component, enter with(DocumentTools) to load the DocumentTools package.
 8 To retrieve a list of components and subsystems in your model, enter GetProperty("Simulation0", "components"). A list of all the components in your model is displayed. Note that the names of components within subsystems take the form :: (for example, the name of the EMF component in the DC Motor subsystem is DCMotor::EMF2).
 9 To retrieve a list of parameters for the top-level Inertia component called I3, enter GetProperty("Simulation0", "I3#parameters").
 10 To change the value of the w_start parameter to 5, enter SetProperty("Simulation0", "I3#w_start", 5).
 11 To verify your change, enter GetProperty("Simulation0", "I3#w_start"). The value that you assigned to the w_start parameter is displayed in the worksheet.

Example 2 - Browsing a model in a Maple worksheet.

1. Open a new Maple worksheet.

2. From the Components palette, click MapleSim component   to insert a MapleSim Model component.

3. Right-click (Control-click for Macintosh) the MapleSim Model component and select Component Properties.

4. Click Select...

5. Browse to the <Maple_install_directory>/toolbox/MapleSim/data/examples directory (where <Maple_install_directory> is the directory in which Maple is installed) and open the FrictionlessSlidingTable.msim example.

6. In the Simulation Properties dialog box, click OK. The model is opened in the MapleSim Model component.

7. From the drop-down menu at the top of the MapleSim Model component, select DC Motor. The detailed view of the DC Motor subsystem is displayed in the MapleSim Model component.

8. Click Main to return at the top of the MapleSim Model component to browse to the top level of the model.

Example 3 - Retrieving a Maple record to view subsystem properties.

1. Open a new Maple worksheet.

2. From the Components palette, click MapleSim component   to insert a MapleSim Model component.

3. Right-click (Control-click for Macintosh) the MapleSim Model component and select Component Properties.

4. Click Select...

5. Browse to the <Maple_install_directory>/toolbox/MapleSim/data/examples directory (where <Maple_install_directory> is the directory in which Maple is installed) and open the FrictionlessSlidingTable.msim example.

6. In the Simulation Properties dialog box, click OK. The model is opened in the MapleSim Model component.

7. Using the navigation controls at the top of the MapleSim Model component, browse to the detailed view of the DCMotor subsystem.

8. At a Maple prompt below the MapleSim Model component, enter with(DocumentTools) to load the DocumentTools package.

9. To retrieve a list of components and subsystems in the model, enter GetProperty("Simulation0", "components").

10. To retrieve a Maple record that displays properties for the DCMotor subsystem, enter GetProperty("Simulation0","DCMotor#type").