CAD Skill Output Format Options in Text-to-CAD: STEP, STL, 3MF, and GLB Explained
The CAD Skill supports STEP/STP as the canonical solid model and generates STL, 3MF, and GLB mesh formats, plus PNG snapshots for rapid previews.
The CAD Skill (cad) in the earthtojake/text-to-cad repository is a thin wrapper around the cadgen distribution that converts textual descriptions into manufacturable 3D models. Understanding the available CAD Skill output format options is essential for integrating generated geometry into workflows ranging from 3D printing to real-time web visualization. All exports derive from a primary STEP document, which serves as the single source of truth for geometric validation.
Supported CAD Skill Export Formats
The cadgen CLI exposes five distinct output categories documented in skills/cad/references/supported-exports.md. Each format serves a specific downstream use case, from engineering analysis to consumer 3D printing.
STEP/STP — The Native Solid Model
STEP (or STP) is the native solid representation and the required foundation for all other exports. When you execute a model script, cadgen first generates this boundary representation file before creating any derivative meshes.
- Command generation:
python <model>.pyproduces the STEP automatically - Validation requirement: All mesh exports must be validated against the primary STEP, as meshes lack topological information required for precise manufacturing analysis
- Source documentation:
skills/cad/references/supported-exports.mdlines 3-4
STL — Standard Tessellated Mesh
STL is the industry-standard tessellated format for 3D printing and rapid prototyping. The CAD Skill generates STL files by meshing the STEP solid with configurable tolerance controls.
- Export command:
cadgen stl build STEP/<model>.step - Ad-hoc export:
cadgen stl build <imported>.step <out>.stlfor external STEP files - Use case: FDM and SLA printer preparation
3MF — Microsoft 3D Manufacturing Format
3MF provides functionality similar to STL but embeds richer metadata including color, material, and print settings. This format is preferred for Windows-centric manufacturing pipelines.
- Export command:
cadgen 3mf build STEP/<model>.step - Documentation reference:
skills/cad/references/supported-exports.mdlines 64-70
GLB — Binary glTF 2.0
GLB exports geometry as a binary glTF 2.0 file optimized for real-time web viewers and game engines. The exporter uses a Y-up axis convention to match web graphics standards.
- Export command:
cadgen glb build STEP/<model>.step - Target platforms: WebGL viewers, Unity, Unreal Engine
PNG Snapshots
Snapshot PNG files provide rendered previews of any generated geometry. The snapshot verb works on STEP files or any mesh export, though mesh snapshots lack CAD-specific viewing options.
- Command pattern:
cadgen <format> snapshot <file> <out.png> - Limitation: Mesh snapshots do not support
--focusor--kinematicsflags because meshes lack the topological data required for CAD camera manipulation
Generating Exports with cadgen Commands
The cadgen CLI provides explicit "door" commands for ad-hoc exports. These work both with models containing declarative decorators and with imported STEP files from external CAD systems.
Run a model to generate the primary STEP and any declared mesh variants:
# Run the model script – creates STEP and any declared meshes (@stl, @glb, etc.)
python models/bracket.py
Export specific mesh formats from the generated STEP:
# Export STL (auto-detects declared @stl decorator if present)
cadgen stl build STEP/bracket.step
# Export 3MF for Windows manufacturing workflows
cadgen 3mf build STEP/bracket.step
# Export GLB with custom tessellation density
cadgen glb build STEP/bracket.step \
--mesh-tolerance 5e-3 \
--mesh-angular-tolerance 0.5
Render preview images:
# Snapshot the STL mesh (note: no CAD view options available)
cadgen stl snapshot STL/bracket.stl tmp/bracket_mesh.png
For external STEP files without a model script, specify an explicit output path:
cadgen stl build path/to/imported.step meshes/imported.stl
Declarative Exports in Model Scripts
The CAD Skill respects declarative exports defined via Python decorators in model scripts stored under models/**/src/. When a script declares @step, @stl, @glb, or @threemf decorators, cadgen automatically writes those formats every time the model regenerates.
Example implementation from the repository (e.g., models/w16/src/w16.py):
@step
@stl
@glb
def build_bracket():
# Model geometry logic here
pass
Running python models/w16/src/w16.py executes the build and exports STEP, STL, and GLB simultaneously without requiring separate CLI commands.
Mesh Tolerance and Quality Control
Mesh exports support fine-grained tessellation control through command-line flags. These override default tolerances defined in the model or cadgen configuration.
--mesh-tolerance: Linear deviation for mesh simplification (default varies by format)--mesh-angular-tolerance: Angular tolerance for curved surface approximation in degrees
Override tolerances for high-fidelity exports:
cadgen stl build STEP/bracket.step meshes/bracket_fine.stl \
--mesh-tolerance 2e-4 \
--mesh-angular-tolerance 0.2
Lower tolerance values produce denser meshes with higher fidelity to the original STEP surface geometry at the cost of increased file size.
Summary
- STEP/STP is the required primary format and sole source of geometric truth; all mesh exports derive from it.
- STL, 3MF, and GLB are supported mesh-based CAD Skill output format options generated via
cadgen <format> buildcommands. - PNG snapshots provide rapid visual previews but lack CAD-specific camera controls when rendered from meshes.
- Declarative decorators (
@stl,@glb,@threemf) enable automatic export generation during model script execution. - Tolerance flags (
--mesh-tolerance,--mesh-angular-tolerance) control tessellation density for all mesh exports.
Frequently Asked Questions
What is the difference between STEP and mesh exports in the CAD Skill?
STEP is a boundary-representation (B-rep) format containing precise topological and geometric data, serving as the master model for engineering validation. Mesh exports (STL, 3MF, GLB) are tessellated approximations generated from the STEP for specific downstream applications like 3D printing or real-time rendering. Validation must always occur on the STEP file, as meshes discard the precise surface definitions required for dimensional analysis.
How do I export multiple formats from a single model script?
Use Python decorators to declare multiple outputs in your model definition. Applying @step, @stl, @glb, and @threemf to the build function causes cadgen to generate all four formats when you run python <model>.py. This declarative approach eliminates the need for separate post-processing CLI commands.
Can I adjust mesh quality when exporting to STL or GLB?
Yes. Append --mesh-tolerance (linear deviation) and --mesh-angular-tolerance (surface curvature accuracy) to any cadgen stl build or cadgen glb build command. Smaller values increase polygon count and surface fidelity, while larger values reduce file size for faster processing.
What are the limitations of PNG snapshots for mesh files?
Mesh snapshots support basic rendering to PNG but cannot utilize CAD-specific view options such as --focus to center the camera on specific faces or --kinematics to visualize moving assemblies. These features require the topological information present only in STEP files, not in the tessellated mesh formats.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →