OS. Set Up Your Coding Environment
In order to program OpenSTAAD in Python, you will need to set up a development environment.
A develop environment is typically a program that supports writing the code as well as a suite of tools to make that job easier. While computer code could be written in any plain text editor, an integrated development environment (IDE) will make the job much easier and more efficient. For this guide, you will use Microsoft Visual Studio Code. This is a popular programming editor which is free to use and supports many different programming languages through a wide array of extensions.
- Download and install Visual Studio Code from https://code.visualstudio.com/
- Install a python interpreter. This is the python language version you will be using. This performs the actual operations of your code. You can download Python from https://www.python.org/downloads/.
- Launch the Visual Studio Code application.
-
Install the Python extension in Visual Studio Code.
The extension is used to help you easily write Python code in the editor. It can also interact with a interpreter to allow you to run and debug the code from within the editor itself.
- Verify the Python installation.
-
Install pywin32.
This allows COM objects to interact with Python and is required for using OpenSTAAD in Python. You will use a package management system built into the Python extension to download an install this.
-
Install the comtypes Python library.
This is a lightweight Python COM package based on the ctypes foreign function library (cyptes is included in Python 2.5 and later). This package makes it easier to access and implement both custom and dispatch-based COM interfaces.
- Open a new terminal window in Visual Studio Code.
- Type pip install comtypes and then press <Enter>. The package is downloaded and installed.
- Close the Powershell window.