STA is a Python-based GUI application for structural analysis, built with Tkinter. It provides interactive tools for modeling, analyzing, and visualizing structural elements like beams, frames, and trusses.
- File Loading: Supports loading structural models from .zap files with automatic encoding detection (UTF-8 or Latin-1).
- Interactive Canvas: Zoom, pan, and fit-to-screen functionality.
- Results Visualization: Display bending moment diagrams, shear force diagrams, axial forces, and displacements.
- Keyboard Shortcuts:
- Ctrl+Z: Undo
- Ctrl+Y: Redo
- Ctrl+0: Reset zoom to 100% and center model
- +/-: Zoom in/out
- Status Bar: Shows current scale, mouse position, and grid/snap status.
- Grid and Snap: Toggle grid display and snapping for precise modeling.
- Ensure Python 3.x is installed.
- Install required dependencies (if any, e.g., NumPy):
pip install numpy - Run the application:
python Sta.py
- Load example files from the
EXAMPLES/folder. - Use mouse to select, add nodes/members, and apply loads.
- Press Ctrl+0 to reset zoom and center the model.
- Analyze the structure and view results in different modes (shear, bending, etc.).
- Primary Objectives: Fix bugs in STA GUI, including file loading failures, runtime errors, diagram inconsistencies, encoding issues, GUI visibility after loading, and zoom/pan features.
- Main Issues Encountered:
- File loading failures (encoding, parsing errors).
- Runtime crashes (division by zero, attribute errors).
- Diagram mismatches between polyline and line rendering.
- Image disappearing after loading (viewport centering).
- Zoom reset (Ctrl+0) hiding the model.
- Resolution Approach: Iterative testing, code fixes, and validation with py_compile and runtime execution.
-
File Loading Fixes (loadsave.py):
- Added encoding detection (try UTF-8, fallback to Latin-1).
- Fixed parsing errors (typos, zero length/material checks).
- Implemented auto-fit after loading for proper centering.
-
Runtime Error Fixes (General):
- Added checks for division by zero and missing attributes.
- Unified bending moment diagram calculations for consistent rendering.
-
GUI and Rendering Updates (canvas.py, draw.py):
- Added fit-to-screen, middle-mouse pan, keyboard zoom (+/-), and scale display.
- Fixed viewport centering post-loading.
-
Zoom and Coordinate Fixes (functions.py, canvas.py):
- Updated
canvasCoordsandtrueCoordsto consistently apply mouseAnchor offset. - Revised
zoom()andzoomReset()for accurate centering. - Ctrl+0 now centers the model without hiding it.
- Updated
- Completed Features: File loading, runtime fixes, diagram consistency, auto-fit, pan, keyboard zoom, status bar.
- Resolved Issues: Zoom reset no longer hides the model.
- Testing: Validated with py_compile (no errors) and runtime execution (exit code 0).
Sta.py: Main GUI and event handlers.canvas.py: Canvas management, zoom, pan, redraw.functions.py: Coordinate transformations.loadsave.py: File I/O and auto-centering.draw.py: Rendering functions.classes.py: Data models.action.py: Undo/redo logic.
- Scrollregion is fixed to (-100000, -100000, 100000, 100000) for large models.
- Coordinate system: Canvas Y increases downward; transformations handle scaling and anchoring.
- Test with example files in
EXAMPLES/to verify functionality.
- Adjusted member direction to be consistent based on global coordinates (vertical: bottom-to-top, horizontal: left-to-right) to ensure bending moment diagrams display the same regardless of drawing order.
- Modified
Member.__init__andupdateinclasses.pyto swap nodes automatically. - Removed flip logic in
functions.pyandrun.pyfor consistent sign convention.
- Division by Zero: Added check in
run.pyto skip members with zero length. - Index Errors: Added bounds checks in
classes.py,draw.py, and other files to prevent crashes from invalid node/member indices. - Square Root Negative: Clamped result in
functions.pyfindProjectionto avoid ValueError. - Load/Save Integrity: Added
original_nodesinMemberclass and updatedloadsave.pyto save original node indices, preventing file corruption from direction swaps.
- Runtime tests pass with improved error handling.
- Load/save operations preserve file structure.
- Bending moment diagrams are now consistent across different drawing directions.