Getting started
Python is a versatile, high-level, and dynamically-typed programming language known for its simplicity and readability. Python enables developers to build a wide range of applications, from web development to data science, automation, and beyond.
This guide shows how to create and run a Python script using Visual Studio Code and the Python command-line interface (CLI). Project tasks, such as creating, editing, and running a script, are managed through the terminal.
The python package is mainly focus on fdscript
automation which will help you in automatise processes as running analysis, design and read results.
The construction of the Database
object is currently out of scope as it is delegated to the users. Database
is based on xml sintax and you can use library such as xml.etree.ElementTree
to manipulate the file.
Prerequisities
-
Visual Studio Code with the Python extension installed. For information about how to install extensions on Visual Studio Code, see VS Code Extension Marketplace.
-
FEM-Design Python API which can be install by
pip install FEM-Design
through your terminal.
Create a python script
-
Start Visual Studio Code.
-
Select File > Open Folder from the main menu.
-
In the Open Folder dialog, create a HelloStruSoft folder and select it. Then click Select Folder
-
Create a new file and save it as program.py.
-
Copy the following script contents in program.py with the following code:
from femdesign.comunication import FemDesignConnection
pipe = FemDesignConnection()
try:
pipe.SetProjectDescription(project_name="Amazing project",
project_description="Created through Python",
designer="Super Engineer",
signature="",
comment="Wish for the best",
additional_info={"italy": "amazing", "sweden": "amazing_too"})
pipe.Detach()
except Exception as err:
pipe.KillProgramIfExists()
raise err
Run the application
Run the following command in the Terminal:
python program.py
Congratulations, you have successfully created your first FEM-Design Application! 🎉
A small range of examples can be found at GitHub. If you need any help or you are looking for new features, give us some feedback by our Community page.