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.
|
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.
|
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 <subsystem_name>::<component_name> (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").