Newer developments

Since 2019, we have set aside development in Python in favor of C#. This is because Python is aimed towards running shorter tasks, while C# is better suited for longer, more complex programs.

 A complete Python wrapper is planned for the future, but unless you specifically want to work within the Python language, we currently recommend that you use C# instead. You can find more information about that on our C# page.

You can find more of our old examples of using Python with the FEM-Design API here:

Save existing model as struxml

In most situations where a script or some kind of automation is needed it is easiest to modify an existing XML file. This can be done in many different ways and in many different programming languages. Start out by modelling the structure in FEM-Design as usual. Then save the model file as a XML-file. The model file can be saved as struxml file by going to "File/Save as..." and choosing struxml as the file type.


You can open and view the xml-file in a text editor to quickly identify what attribute or text that you want to modify. We recommend XML Notepad or Notepad ++.

Example 1 - Pile stiffness

Example 1 - Pile stiffness⭳ Download example 1

The current example will illustrate how to modify an existing XML file to adjust the stiffness of a point support with regard to the reaction in the support. This will illustrate how to make changes to the model, run the analysis and then make additional changes depending on the result. This is a very common situation and the main work flow can be used in many different situations, for example optimization. 

To better understand the final code, please see the picture below. 

Identify and save original gamma factors1560771228867-938.png
Read model file1560771289380-245.png
Write new gamma factors with regard to load step1560771347907-586.png
Run analysis1560771478731-491.png
Read model file1560771542309-517.png
Read reactions1560771684392-495.png
Write new support stiffness1560771755994-352.png

NOTE: To get the script to work you have to check the file path inside the python code and also in the script-file.


Example 2 - Parametric wall

Example 2 - Parametric wall⭳ Download example 2

This example will illustrate how to create a parametric wall. The goal is to be able to adjust different measurements of an existing wall to make modelling more efficient and minimize errors. The example is a prefabricated wall and the measurements that should be parametric are:

wallHeightThe total height of the wall [m]
wallLengthThe total length of the wall [m]
windowXThe x-position of the window [m]
windowYThe y-position of the window [m]
windowWThe window width [m]
doorPosThe position of the door [m]
connectionCapacityThe connection capacity for each of the point connections [kN]


The code will use an existing wall model saved as struxml and change different parameters with regard to the defined parameters. This file is included in the example. It is recommended to have some kind of input check so that the input values are possible to model, for example doorPos+1 < wallLength. This is however not included in the example.

NOTE: Place the python script and the model file in the same directory to get the code to run.

Example 3 - Convergence study

Example 3 - Convergence study⭳ Download example 3 

This example will illustrate how to create a simple script to adjust the mesh settings to perform a convergence study. Please note that the script is using the FEM-Design Python wrapper. Download the wrapper and place it in the same folder as the script. 

The script is also using the libraries Element tree, CSV and openpyexcel. They are available through pip install.

Disclaimer: All example files, wrappers and documentation are for illustrative and educational purposes and may not interact with FEM-Design in a reliable way depending on your version, installation and content of the files. Furthermore, StruSoft won´t guarantee full support of the API functions since they are customizable by the customer.

Tags: API
Copyright 2022 StruSoft AB
FEM-Design Wiki