| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → SimMechanics Link |
| Contents | Index |
| Learn more about SimMechanics Link |
| On this page… |
|---|
In the following procedures, replace:
matlabroot with the root of your MATLAB installation.
ARCH with the specific operating system architecture abbreviation for your system (for example, win32 for 32-bit Windows).
To write your C/C++ custom exporter module, use the C header file located in matlabroot/toolbox/physmod/smlink/api/include/.
This header file contains the function definitions that you follow to call the SimMechanics Link API functions from your module. Include this header file in your module C/C++ source code.
In addition to linking your custom module to the SimMechanics Link API, consult your CAD platform's API documentation to determine requirements for linking to the platform's API.
On Windows Platforms. After you compile your module, link it to the binary API function library located in matlabroot\toolbox\physmod\smlink\api\lib\.
On UNIX, LINUX, and Mac Platforms. After you compile your module, link it to the binary API function library:
matlabroot/bin/ARCH/libmwpmi_api.OS-SPECIFIC-EXTENSION
OS-SPECIFIC-EXTENSION is the API file extension specific to your operating system.
To determine if you need to include your CAD platform API on the path, consult your CAD platform API documentation.
On Windows. Before you start execution of the module, verify that the folder matlabroot\bin\ARCH\ is on the path.
On UNIX, LINUX, and Mac Platforms. Before you start execution of the module, verify that the folder matlabroot/bin/ARCH/ is included in the system path environment variable LD_LIBRARY_PATH.
You can find API examples in this folder:
matlabroot/toolbox/physmod/smlink/api/example/
The subfolder, cadapi_example/, contains CAD-based examples.
The folder matlabroot/toolbox/physmod/smlink/api/example/cadapi_example/ contains a simple C++ example of a custom module based on the API, cadapi_example.cpp.
The example custom module converts two CAD parts with one constraint into two SimMechanics bodies and one joint and then writes the result to a Physical Modeling XML file.
The example program defines the CAD assembly data internally, rather than taking the data from a CAD platform through the platform API. Compared to the figure, Custom Exporter Module Communicates with APIs (Detail) preceding, the leftmost portion of the diagram is missing.
To extend the example module to process real assembly data, add code that calls a CAD platform's API for assembly data to replace the internally defined data.
![]() | Designing Custom Exporter Modules |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |