Skip to content

Homi/STA-GUI

Repository files navigation

STA GUI - Structural Analysis Tool

Overview

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.

Features

  • 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.

Installation

  1. Ensure Python 3.x is installed.
  2. Install required dependencies (if any, e.g., NumPy):
    pip install numpy
    
  3. Run the application:
    python Sta.py
    

Usage

  • 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.).

Debugging and Update Log

Overview of Debugging

  • 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.

Detailed Updates

  1. 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.
  2. Runtime Error Fixes (General):

    • Added checks for division by zero and missing attributes.
    • Unified bending moment diagram calculations for consistent rendering.
  3. 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.
  4. Zoom and Coordinate Fixes (functions.py, canvas.py):

    • Updated canvasCoords and trueCoords to consistently apply mouseAnchor offset.
    • Revised zoom() and zoomReset() for accurate centering.
    • Ctrl+0 now centers the model without hiding it.

Current Status

  • 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).

Key Modules

  • 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.

Notes

  • 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.

Recent Fixes (April 2026)

Bending Moment Diagram Consistency

  • 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__ and update in classes.py to swap nodes automatically.
  • Removed flip logic in functions.py and run.py for consistent sign convention.

Bug Fixes

  • Division by Zero: Added check in run.py to 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.py findProjection to avoid ValueError.
  • Load/Save Integrity: Added original_nodes in Member class and updated loadsave.py to save original node indices, preventing file corruption from direction swaps.

Testing

  • Runtime tests pass with improved error handling.
  • Load/save operations preserve file structure.
  • Bending moment diagrams are now consistent across different drawing directions.

About

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.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors