ops-code
Run openseespy models directly in VS Code with instant 3D visualization and interactive analysis results.
Quick Start
Features
Example
Requirements
To install openseespy:
Optional: Configure the Python path in VS Code settings if auto-detection fails. Viewer Configuration (
|
| Field | Type | Required | Description |
|---|---|---|---|
tag |
int |
yes | element tag |
name |
str |
yes | result label |
value |
int \| float \| str \| bool |
yes | result value |
description |
str |
no | longer description shown in panel |
def run(outputs: dict) -> dict:
results = []
for el in outputs["elements"]:
N = el["responses"]["localForce"][0]
results.append({
"tag": el["eleTag"], # int — element tag
"name": "N", # str — result label
"value": round(N, 2), # int | float | str | bool
"description": "axial force (kN)", # str — optional
})
return {"elements": results}
ops-code exposes analysis results to tools via the outputs dict. Section data is only available for Truss, TrussSection, CorotTruss, and elasticBeamColumn elements.
| Key | Contents |
|---|---|
nodes |
{tag, coords, displacement, reaction} per node |
elements |
{eleTag, type, nodes, responses: {localForce}} per element |
sections |
{eleTag, type, E, A, Iy?, Iz?, G?, J?} — supported element types only |
Declaring Tools in Your Model
Tools are opt-in. Declare which tools apply to a model with a standard Python import:
import openseespy.opensees as ops
from tools import buckling_en1993
Only tools imported in your model file are run.
Current Limitations
- Tools run only after Run Analysis — they require analysis results
forceBeamColumnanddispBeamColumnsection data is not resolved; those elements have no entry inoutputs["sections"]
Known Limitations
- 2D and 3D frame elements only (truss, beam, elasticBeamColumn)
- Distributed element loads not yet included in section force diagrams
- Requires
openseespyfor analysis; model geometry loads without it
Configuration
Set optional preferences in VS Code settings:
ops-code.pythonPath— Path to Python interpreter (auto-detected if blank)ops-code.autoRenderOnSave— Re-render model on file save (default: true)
Development
Setup
Clone the repository:
git clone https://github.com/igor-barcelos/ops-code.git cd ops-codeInstall dependencies:
npm installBuild the extension:
npm run build
Running in Debug Mode
- Open the project in VS Code
- Press F5 or go to Run → Start Debugging
- A new VS Code window opens with the extension active
- Open a
.pyfile and test: right-click → "Run in ops-code"
Development Workflow
Watch mode — Auto-rebuild on file changes:
npm run watchBuild and package VSIX — Create a distributable package:
npm run bundlePackage only — Create VSIX file (after build):
npm run package
License
MIT — see LICENSE file for details.
