Module SDK Quick Start

Overview and Key Concepts

This document explains how to create a FlexSim module quickly and easily. Before starting, make sure you have the latest version of Visual Studio (Community or Professional) installed.

Preparing for Module Development

These steps are more general, and usually only need to be done once, even if you are developing multiple modules.

Making a Development Version of FlexSim

To prepare for module development, we recommend that you make a development version of FlexSim. This can be done in two easy steps:

  1. In your Documents folder, make a new folder called "ModuleDevelopment" or a similar helpful name
  2. Copy C:\Program Files\FlexSim 2021 (or the latest version of FlexSim) and paste it into your development directory

This creates a copy of FlexSim. During development, you should use this copy of FlexSim. For convenience, you may want to make a shortcut to this version:

  1. In your development directory, navigate to FlexSim\program
  2. Right click on flexsim.exe and choose Create Shortcut
  3. Name the shortcut something like "FlexSimDev" and move it to your desktop

If you desire, you can configure the development copy of FlexSim to use a different User Preferences file. (This makes it so the development copy can be put in development mode, and leaves the intalled copy alone.)

  1. In your development directory, navigate to FlexSim\program
  2. Open the file called productid.txt in a text editor
  3. Change the first line to a meaningful name, like ModuleDev

You can make as many development versions of FlexSim as you need.

Enabling Development Tools in FlexSim

FlexSim has some development tools built in, but they are not enabled by default. To enable them, do the following:

  1. Open your development version of FlexSim
  2. Add a node at VIEW:/environment/dev
  3. Give that node number data, and set it to 1
  4. Close FlexSim (which saves the new node as a user preference)

Next time you open FlexSim, the dev node will still be there, and additional options will be available in your right-click menu.

Creating a Save Defaults Button

As you add nodes to the tree as part of your module, you will want to save your progress. The most convenient way to do this is to add a button to FlexSim to save your module changes:

  1. Open your development version of FlexSim
  2. From the File menu, open the Global Preferences window
  3. On the Customize Toolbar tab, add a new button
  4. Select the new button in the list, and click Edit Item
  5. Change its name to "Save Defaults", and replace the example code with the following: applicationcommand("savedefaultviewproject");
  6. Click OK, then click Apply and Close
  7. Close FlexSim to save these changes to global preferences

Creating a New Module

Now you are ready to create a new module. Choose a name for your module. It should be helpful and short, and should not contain any spaces. Good example names include "ProcessFlow" and "AStar".

In order to create a new module, you need to create a folder for the new module. Do so as follows:

  1. In your development directory, navigate to FlexSim\modules
  2. Create a new folder with the name of your module

Next, you need to add the essential module nodes to FlexSim:

  1. Open your development version of FlexSim
  2. In the tree, go to MAIN:/project/modules
  3. Add a node with the name of your module
  4. Add a subnode to that node called installdata
  5. Click the Save Defaults button

Adding Nodes

Once you have completed these steps, you can begin adding nodes to your module:

  1. Add a node to the tree
  2. Right-click the node
  3. Choose Modules > [ModuleName] > Add as Addition

Once you have added a node to your module, you can edit that node by giving it data or subnodes. When you have finished editing that node, click the Save Defaults button to save your work.

Adding a DLL Project to your Module

Some modules extend FlexSim's functionality with custom C++ code. In order to do this, follow these steps:

  1. Download module_template.zip
  2. Extract the ModuleDLL folder to FlexSim\modules\[ModuleName] in your development directory
  3. Copy the files from FlexSim\program\system\include to the ModuleDLL\flexsimcontent directory
  4. Copy flexsim.lib from FlexSim\program\system\lib to the ModuleDLL\flexsimcontent directory
  5. Open the ModuleDLL\module.sln file in the latest version of Visual Studio
  6. In the Solution Explorer pane, right-click the project and select Rename
  7. Rename the project from "module" to the name of your module
  8. Build the solution. It should build and link without any errors. A [ModuleName].dll file should be generated in your module's directory.