Skip to content

Latest commit

Β 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

BOMcad - Universal 3D CAD & Mesh Analyzer

BOMcad is a web-based, interactive 3D CAD and mesh analysis tool. It processes B-Rep engineering CAD files (STEP, IGES) and mesh files (STL, OBJ, GLTF, GLB) to calculate volume, surface area, center of mass, bounding boxes, and to generate custom Bills of Materials (BOM) with interactive weight calculations and multiple export formats.

The app uses OpenCascade (via CadQuery) for high-fidelity solid modeling parsing and Trimesh for mesh rendering and conversion, wrapped in a lightweight, responsive FastAPI web application.


πŸš€ Key Features

  • Multi-Format Support:
    • B-Rep CAD: STEP (.step, .stp), IGES (.iges, .igs)
    • Mesh Formats: STL (.stl), OBJ (.obj), GLTF/GLB (.gltf, .glb)
  • 3D Interactive Viewer: Render full assembly files directly in the browser with orbital control, component highlighting, and distinct visual coloring for each part.
  • Automated Physical Metrology:
    • Volume ($cm^3$) and Surface Area ($cm^2$) calculations per component.
    • Bounding box dimensions (envelope length, width, height) in millimeters.
    • Precise Center of Mass (COM) coordinates.
  • Interactive BOM Generator:
    • Assign standard engineering materials (Steel, Aluminum, Titanium, Copper, PLA, Carbon Fiber, etc.) or set a custom density.
    • Recalculate weights instantly for individual components or the entire assembly.
  • Multi-Format Analytical Reports: Export reports instantly in PDF, Excel (XLSX), CSV, or raw JSON formats.

πŸ› οΈ System Architecture

The application is structured into a clean decoupled backend API and a fast, pure Javascript frontend:

graph TD
    User([User Client]) -->|Upload CAD/Mesh| API[FastAPI Backend]
    API -->|STEP / IGES| CQEngine[CadQuery / OpenCascade Engine]
    API -->|STL / OBJ / GLTF| TMEngine[Trimesh Engine]
    CQEngine -->|Calculates Metrology & Exports GLB| ModelStore[(static/models)]
    TMEngine -->|Calculates Metrology & Exports GLB| ModelStore
    API -->|Serve Metadata & GLB| User
    User -->|View 3D WebGL Model| ThreeJS[Three.js / Model Viewer]
    User -->|Interactive Recalculate| API
    User -->|Download Reports| API
Loading

πŸ“‚ Repository Structure

β”œβ”€β”€ main.py                # FastAPI Application & REST Endpoints
β”œβ”€β”€ cad_parser.py          # OpenCascade (CadQuery) & Trimesh parsing engine
β”œβ”€β”€ test_analyzer.py       # Automated suite of test fixtures for geometry pipelines
β”œβ”€β”€ requirements.txt       # Python Dependencies
β”œβ”€β”€ static/                # Single Page Frontend Application (SPA)
β”‚   β”œβ”€β”€ index.html         # Main dashboard layout (semantic HTML5, SEO structured)
β”‚   β”œβ”€β”€ index.css          # Modern slate-styled dashboard interface
β”‚   β”œβ”€β”€ app.js             # Visual rendering & BOM interactivity controller
β”‚   └── models/            # Temporary storage for generated WebGL GLB models (Git-ignored)
β”œβ”€β”€ samples/               # Sample CAD files for user testing (IGES format)
β”œβ”€β”€ uploads/               # Temporary CAD files (Git-ignored)
└── reports/               # Generated reports in CSV, XLSX, PDF (Git-ignored)

πŸ“₯ Test Samples

To help you get started testing the application quickly, we have provided some sample IGES CAD models inside the samples/ folder:

  • cube_with_hole.igs: A basic solid cube ($20 \times 20 \times 20\text{ mm}$) featuring a center vertical hole. Great for verifying standard geometric calculations.
  • simple_bracket.igs: A typical structural L-bracket ($40 \times 20 \text{ mm}$ base, $30\text{ mm}$ upright). Ideal for checking multi-axis bounds and volumes.
  • assembly_sample.igs: A multi-component assembly containing a box solid and a cylinder solid. Perfect for testing assembly breakdowns, multi-part interactive listing, and distinct color rendering.

Feel free to download any of these files and upload them to the web interface to verify analysis features!


βš™οΈ Installation & Setup

Prerequisites

  • Python 3.9 - 3.11 (Note: cadquery requires a compatible Python version, typically 3.9 or 3.10 is recommended for pre-built binaries).
  • A system with OpenCascade binaries available (usually installed automatically via pip with cadquery).

Steps

  1. Clone the repository:

    git clone https://github.com/tsm56/BOMcad.git
    cd BOMcad
  2. Set up a virtual environment:

    python -m venv .venv
    # Windows:
    .venv\Scripts\activate
    # macOS/Linux:
    source .venv/bin/activate
  3. Install dependencies:

    pip install --upgrade pip
    pip install -r requirements.txt
  4. Run the application:

    uvicorn main:app --reload
  5. Open the web dashboard: Navigate to http://127.0.0.1:8000 in your web browser.


πŸ§ͺ Testing

BOMcad includes a suite of test cases to verify CAD and mesh translation correctness. Run the tests using:

python -m pytest test_analyzer.py

πŸ“œ License

Distributed under the MIT License. See LICENSE for more details.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages