Skip to content

viktor-platform/sample-staad-integration

Repository files navigation

STAAD.Pro Sample App

This repository demonstrates how to connect a VIKTOR app with STAAD.Pro by using the VIKTOR Python worker. The sample app creates a steel frame in STAAD.Pro, adds a self-weight load case, runs the analysis, and returns member end forces to the VIKTOR interface.

The worker script uses Bentley's official openstaadpy package for STAAD.Pro 2025 and newer. For older STAAD.Pro versions, use the legacy OpenSTAAD COM approach with pywin32 and comtypes.

Step 1

Step 1

Repository contents

  • app.py: VIKTOR app code. It sends inputs.json to the Python worker through viktor.external.python.PythonAnalysis and reads back output.json.
  • run_staad_model.py: Python worker script that opens or connects to STAAD.Pro, creates the model through OpenSTAAD, runs the analysis, and writes output.json.
  • worker-requirements.txt: Python packages to install in the Python environment used by the VIKTOR worker.
  • viktor.config.toml: VIKTOR app configuration with the Python worker integration enabled.

Requirements

VIKTOR app environment

Install the app requirements:

pip install -r requirements.txt

Python worker machine

The Python worker must run on the same machine or server where STAAD.Pro is installed and licensed.

For STAAD.Pro 2025 and newer, install the worker dependencies in the Python environment selected during the Python worker installation:

pip install -r worker-requirements.txt

The official package is installed from Bentley's GitHub repository:

pip install git+https://github.com/BentleySystems/openstaadpy.git

For STAAD.Pro versions older than 2025, use the legacy OpenSTAAD COM approach instead:

pip install pywin32 comtypes

Worker configuration

This sample uses the VIKTOR Python worker and PythonAnalysis:

from viktor.external.python import PythonAnalysis

The app sends the worker script and an input file to the worker:

input_json = json.dumps([nodes, lines, cross_section])
script_path = Path(__file__).parent / "run_staad_model.py"
script = File.from_path(script_path)

files = [
    ("inputs.json", BytesIO(input_json.encode("utf-8"))),
]

staad_analysis = PythonAnalysis(
    script=script,
    files=files,
    output_filenames=["output.json"],
)
staad_analysis.execute(timeout=300)
output_file = staad_analysis.get_output_file("output.json")
output = json.loads(output_file.getvalue().decode("utf-8"))

App configuration

To make the Python worker integration available in the VIKTOR interface, viktor.config.toml includes:

worker_integrations = [
    "python",
]

Manual Python worker installation instructions are available in the VIKTOR documentation.

STAAD.Pro executable path

run_staad_model.py first tries to connect to an already running STAAD.Pro instance. If no running instance is available, it tries to launch STAAD.Pro from common installation paths for STAAD.Pro 2025 and newer.

If STAAD.Pro is installed in a custom location, set the STAAD_PRO_EXECUTABLE environment variable on the worker machine:

$env:STAAD_PRO_EXECUTABLE = "C:\Program Files\Bentley\Engineering\STAAD.Pro 2025\STAAD\Bentley.Staad.exe"

Notes

  • openstaadpy requires STAAD.Pro to be installed and an OpenSTAAD-enabled STAAD.Pro instance to be available.
  • STAAD.Pro 2025 and newer should use openstaadpy.
  • Older STAAD.Pro versions should use direct OpenSTAAD COM automation through pywin32 and comtypes.
  • Keep the worker Python environment separate from the VIKTOR app environment. STAAD.Pro dependencies only need to be installed on the worker machine.

About

Template application for integrating Bentley STAAD.Pro with VIKTOR using OpenSTAAD and the official Bentley openstaadpy package. Automate structural model creation, STAAD.Pro analysis, and member force extraction.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages