Start from Scratch
This guide will walk you through the process of setting up your environment to use OpenStaad Python, starting from scratch. By the end, you'll have everything you need to write and execute your first OpenStaad Python script.
Prerequisites
Before starting, ensure you have the following:
- A computer running Windows (required for Staad.PRO).
- An active license for Staad.PRO.
Step 1: Install Staad.PRO
- Download Staad.PRO from the Bentley Systems website.
- Follow the installation instructions provided by Bentley.
- Ensure that Staad.PRO is installed and activated with a valid license.
Step 2: Install Visual Studio Code
- Download Visual Studio Code (VS Code) from the official website.
- Run the installer and follow the setup instructions.
- Once installed, open VS Code and install the following extensions:
- Python (by Microsoft): Provides Python support in VS Code.
- Markdown All in One (optional): For better Markdown editing.
Step 3: Install Python
- Download Python from the official Python website.
- During installation, ensure you check the box "Add Python to PATH".
- Verify the installation by opening a terminal (Command Prompt or PowerShell) and running:
You should see the installed Python version.python --version
Step 4: Install OpenStaad Python
- Open a terminal (Command Prompt or PowerShell).
- Install OpenStaad Python using pip:
pip install openstaad - Verify the installation by running:
You should see details about the OpenStaad package.pip show openstaad
Step 5: Create Your First OpenStaad Python Script
- Open Visual Studio Code.
- Create a new file and save it with a
.pyextension (e.g.,first_openstaad_script.py). - Write the following code to test your OpenStaad installation:
from openstaad import Geometry # Create an instance of the Geometry class geometry = Geometry() # Get a list of beams in the model beam_list = geometry.GetBeamList() # Print the beam list print("Beam List:", beam_list) - Save the file.
- Open Staad.PRO and load a model file.
- In the terminal, navigate to the directory where your script is saved and run:
python first_openstaad_script.py - You should see the output of the beam list in the terminal.
Step 6: Explore OpenStaad Python
Now that you have your first script running, you can explore the OpenStaad Python library further.