This is the repository for the tutorial "Exporting and importing an FMU using C code" presented at the Modelica and FMI Conference 2025.
Developers who want to import or export models as FMUs or couple their tool to other tools using FMI.
- install uv
- install Visual Studio or your favorite IDE that's supported by CMake
- clone this repository recursively
git clone --recursive https://github.com/modelica/fmi-import-export-tutorial-2025.git
- meta information
- interface types
- variables, causality, variability
- model structure
- documentation
- resources
- binaries
- source code
- FMU structure
- schema
- headers
- resources: FMI Spec, FMI Implementers Guide
- generate scaffolding with FMPy
- compile & run with FMPy
- set up a CMake project
- run FMU with fmusim
- log FMI calls
- provide input
- save output
- debug
- attach a debugger to FMPy
- debug with fmusim
- read model description
- load shared library
- load symbols
- call functions
Challenges:
- extract the FMU
- read & validate model description
- validate structured variable names
- check return codes
- log messages
- log API calls
- clone repo
- create a CMake project
- get inspiration from Reference FMUs examples and fmusim
- debug import and export with Visual Studio
