LinkModel - MapleSim Help

Online Help

All Products    Maple    MapleSim

Home : Support : Online Help : MapleSim : MapleSim Application Programming Interface : API Commands : MapleSim/LinkModel


link to a MapleSim model


Calling Sequence







Calling Sequence






(optional) equation(s) of the form name = value



module : evaluated ModelObject with the following exports:


ApplySubstitutions substitute simpler names for parameters and variables


DeleteAttachment  delete an attachment (such as a template or a file) from the model


GetAttachment return an attachment of the model


GetCompiledProc compile the active subsystem into executable code


GetEquations return the equations of the system or subsystem


GetICs return the initial conditions


GetModel return the name of the linked model


GetModelica return the Modelica description for the active subsystem


GetMultibody return the multibody portion of the active subsystem


GetParameters return the parameters of the active subsystem


GetPorts return ports and/or probes of a system or subsystem


GetProbes return probes of a system or subsystem


GetSettings return simulation settings (such as the simulation time, solver, and tolerances)


GetSubstitutions return substitution equations (used to create simpler parameter/variable names)


GetSubsystemName return the name of the active subsystem


GetVariables return the variables of the active subsystem


Linearize linearize the equations of the active subsystem


ListAttachments list the attachments (such as the templates, files, and data) of the model


ListSubsystems list the subsystems of the system


SetAttachment attach data to the model


SetComponent create a component from Modelica source


SetModel link to a particular model


SetParameters assign values of parameters


SetSubstitutions assign substitutions (to create simpler parameter/variable names)


SetSubsystemName assign the active subsystem


ShowResultsManager open the Results Manager window


Simulate simulate the system



filename : string


Specifies the filename containing the MapleSim model (.msim). Default is "".


component : string


Specifies the name of the MapleSim Model embedded component to link to. Default is "Simulation0".


modelica : [string, string or use_last_model] or string


Specifies the Modelica model to link to. If a list is given, the first string specifies the filename where the Modelica model is defined, the second string specifies the name of the model inside the file to link to. The model name is needed because one Modelica file can define several models. Alternatively, you can pass the use_last_model keyword, to link to the last model defined in the file. If only one model is defined in the file, you can pass just the string specifying the filename. Default is ["", ""].



The LinkModel command returns a "connection module" that allows programmatic access to a MapleSim model.


Important: You must first link to a MapleSim model as described on this page before accessing the MapleSim API commands for your model.


There are two ways to link to a MapleSim model: by filename or by using a MapleSim Model embedded component.  See the Examples section on this page for more information.


Alternatively, you can link to a Modelica model using the modelica option.


The LinkModel command is part of the MapleSim package.  You can access this command using the long form of the command name, MapleSim:-LinkModel, or by first executing with(MapleSim) and then using the short form of the command name, LinkModel.



Executing LinkModel( ) without options is equivalent to executing LinkModel(component="Simulation0");


When linking to a model using a Modelica file, the following export commands can not be used:








SetSubstitutions with savewithmodel = true


Example 1: Linking to a MapleSim model by specifying a filename. (The model is located in an .msim file.):


Example 2: Linking to a MapleSim model by using a MapleSim Model embedded component.


Open a new Maple worksheet.


From the Components palette, click the MapleSim Model component icon (  ) to insert a MapleSim Model embedded component.


Right-click (Control-click for Macintosh) the MapleSim Model component and then select Component Properties. The Simulation Properties window appears.


Beside File, click Select... and browse to a MapleSim model.


Select a model to open. Click Open.  The Simulation Properties window appears.


Click OK. The model appears in the MapleSim Model component.  If desired, you can browse your model by using the navigation tools at the top of the MapleSim Model to navigate to a subsystem.


Execute the following command to complete the link to the model (and subsystem, if selected) shown in the MapleSim Model component: AMapleSim:-LinkModel

Example 3: Linking to a Modelica model.

Using the name of the model:


Using the last model defined in the file:


See Also