Files
metabuilder/cadquerywrapper/README.md
johndoe6345789 a8144a5903 feat: Add CadQuery wrapper library for parametric CAD modeling
Python wrapper around CadQuery for simplified 3D CAD operations with
clean API for creating shapes, performing boolean operations, and
exporting to various formats.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-21 17:22:38 +00:00

1.7 KiB

CadQueryWrapper

CadQueryWrapper is a lightweight wrapper around CadQuery/cadquery. It provides a small validator for checking model parameters against 3D printer rules.

Installation

If Python is not available on your system, run the helper script. Use the Bash version on Linux and macOS or the batch version on Windows:

./install_python.sh
install_python.bat

Both scripts are self-contained and do not require Python to run.

Then install the runtime dependencies with:

pip install -r requirements.txt

For running the test suite use the development requirements instead:

pip install -r requirements-dev.txt

Usage

import cadquery as cq
from cadquerywrapper import CadQueryWrapper, ValidationError

# create a CadQuery model
wp = cq.Workplane().box(1, 1, 1)

# load rules and create a wrapper using the workplane
wrapper = CadQueryWrapper("cadquerywrapper/rules/bambu_printability_rules.json", wp)

# validate using default rules
try:
    wrapper.validate()
except ValidationError as exc:
    print("Model invalid:", exc)

# exporting will raise ValidationError if parameters fail
wrapper.export_stl("out.stl")

See examples/Ex001_Simple_Block.py for a complete script that validates and saves a simple block model using CadQueryWrapper.

Code Style

See CODE_STYLE.md for contribution guidelines. Monkey patching is prohibited.

🖥 Setup Instructions

Run the setup script for your operating system:

Linux:

chmod +x setup_linux.sh
./setup_linux.sh

macOS:

chmod +x setup_mac.sh
./setup_mac.sh

Windows (PowerShell):

.\setup_windows.ps1

After installation:

poetry shell