- Nim 96.5%
- Python 3.5%
|
|
||
|---|---|---|
| reports | ||
| src | ||
| example_2point.toml | ||
| example_3point.toml | ||
| example_6point.toml | ||
| example_8point.toml | ||
| example_asymmetric.toml | ||
| example_input.toml | ||
| generate_test_files.py | ||
| imgui.ini | ||
| nim.cfg | ||
| README.md | ||
| sling | ||
| sling.nimble | ||
| sling_calc.log | ||
| Sling_length_test_data_20251021.csv | ||
| stay_8pt.toml | ||
| test_case_001.toml | ||
| test_case_002.toml | ||
| test_case_003.toml | ||
| test_case_004.toml | ||
| test_case_005.toml | ||
| test_case_006.toml | ||
| test_case_007.toml | ||
| test_case_008.toml | ||
| test_case_009.toml | ||
| test_case_010.toml | ||
| test_case_011.toml | ||
| test_case_012.toml | ||
| test_case_013.toml | ||
| test_case_014.toml | ||
| test_case_015.toml | ||
| test_case_016.toml | ||
| test_case_017.toml | ||
| test_case_018.toml | ||
| test_case_019.toml | ||
| test_case_020.toml | ||
| test_case_021.toml | ||
| test_case_022.toml | ||
| test_case_023.toml | ||
| test_case_024.toml | ||
| test_case_025.toml | ||
| test_cogval.nim | ||
| VIEWPORT.md | ||
Sling Length Calculator
A Nim-based CLI tool for calculating required sling lengths for lifting operations.
Phase 1 - Current Features
- Calculate sling lengths based on COG (Center of Gravity) and pick point locations
- Support for variable pick points (minimum 2, typically 2-8, no upper limit)
- Works with any lift configuration: 2-point beams, 3-point triangular, 4-point rectangular, 6-point hexagonal, 8-point octagonal, etc.
- TOML input file format
- Configurable minimum sling angle
- Three logging levels: error, warn, info
- Automatic logging to file with all operations
- 3D CAD-style viewport visualization with OpenGL (see VIEWPORT.md)
- Z-up coordinate system (CAD/engineering convention)
- Professional PDF report generation with LaTeX (engineering-grade documentation)
Installation
- Ensure you have Nim installed (>= 2.0.8)
- Install dependencies:
nimble install
Usage
Basic usage:
./sling --inputFile=example_input.toml
With 3D viewport visualization:
./sling --inputFile=example_input.toml --view
With PDF report generation:
./sling --inputFile=example_input.toml --report
With custom report output directory:
./sling --inputFile=example_input.toml --report --reportPath=./my_reports
With custom log level:
./sling --inputFile=example_input.toml --logLevel=error
Available log levels:
error: Only errors printed to consolewarn: Warnings and errors printed to consoleinfo: All messages printed to console (default)
All logs are always written to sling_calc.log regardless of console log level.
Input File Format
Example TOML file:
[project]
name = "Lift Operation XYZ"
date = "2025-10-17"
engineer = "John Doe"
[parameters]
min_sling_angle = 45.0 # Minimum allowable sling angle in degrees
[cog]
x = 1.5
y = 1.2
z = 0.5
[[pick_points]]
name = "P1"
x = 0.0
y = 0.0
z = 1.0
[[pick_points]]
name = "P2"
x = 3.0
y = 0.0
z = 1.0
[[pick_points]]
name = "P3"
x = 3.0
y = 2.5
z = 1.0
[[pick_points]]
name = "P4"
x = 0.0
y = 2.5
z = 1.0
Example Files
The repository includes example files demonstrating different lift configurations:
example_input.toml: 4-point symmetrical rectangular lift (COG at center)example_asymmetric.toml: 4-point asymmetrical lift (offset COG)example_2point.toml: 2-point beam lift (simple spreader beam)example_3point.toml: 3-point triangular liftexample_6point.toml: 6-point hexagonal lift (for large circular loads)example_8point.toml: 8-point octagonal lift (for very large/heavy loads)
Test any configuration:
./sling --inputFile=example_6point.toml
./sling --inputFile=example_3point.toml --view # with 3D visualization
Output
The program outputs to console:
- Hook point coordinates (positioned above COG)
- Calculated sling length for each pick point
- Horizontal distance from COG to each pick point
- Sling angle from vertical for each sling
PDF Reports
When using the --report flag, the program generates professional engineering-grade PDF reports containing:
- Project Information: Name, date, engineer, number of pick points, minimum angle
- Coordinate System: CAD/engineering convention documentation (Z-up)
- Input Parameters: Tables with COG position and all pick point coordinates
- Calculation Methodology: Step-by-step mathematical formulas with LaTeX formatting
- Results: Hook point location, sling lengths and angles with color-coded status (green = OK, red = FAIL)
- Summary: Pass/fail status, angle ranges, hook height, and safety notes
Requirements: pdflatex must be installed and available in PATH. On Arch Linux: sudo pacman -S texlive-basic texlive-latex
Reports are saved to ./reports/ by default (customizable with --reportPath). Auxiliary files (.tex, .aux, .log) are automatically cleaned up after PDF generation.
Phase 2 (Planned)
Future enhancements:
- Tension and strength calculations
- Safety checks (COG validation, tipping hazard detection)
- Standard sling matching (fixed vs adjustable)
- 3D graphical diagrams in PDF reports
- Additional CLI flags for parameter overrides
Project Structure
src/
├── sling.nim # Main entry point
└── sling_calc/
├── types.nim # Data structures (Pt type with labels)
├── logger.nim # Logging system
├── input_parser.nim # TOML parsing with validation
├── calculator.nim # Core sling calculations (variable pick points)
├── viewport.nim # 3D OpenGL/ImGui visualization
└── latex_report.nim # Professional PDF report generation
License
MIT