How to Integrate text-to-CAD into an Existing Workflow
You can integrate text-to-CAD into existing workflows by installing the Skill CLI for shell-based automation or importing the cadpy Python library for programmatic CAD generation, supporting formats like STEP, URDF, and G-code directly from natural language prompts.
The earthtojake/text-to-cad repository provides a full-stack CAD generation ecosystem that bridges natural language prompts with production-ready engineering formats. Whether you are automating mechanical design workflows or embedding CAD generation into robotic simulation pipelines, understanding how to integrate text-to-cAD into an existing workflow allows you to leverage both high-level CLI tools and low-level Python APIs. The architecture centers on the reusable cadpy package, while thin Skill CLI wrappers provide language-agnostic entry points.
Understanding the text-to-CAD Architecture
The system follows a clear data flow from prompt to exportable asset. User input flows through Skill CLI parsers into the cadpy library, which constructs abstract CAD models before exporting to industry-standard formats.
The cadpy Core Library
The cadpy package serves as the engine for all geometry operations. Located at packages/cadpy/src/cadpy/api.py, this library exposes the CadModel class and functions like generate_step, generate_urdf, and render_glb. Heavy lifting for mesh generation, assembly flattening, and metadata handling occurs in sub-modules such as assembly.py, step_export.py, and glb.py. Direct Python integration requires only importing from this core package.
Skill CLI Wrappers
Individual skills provide self-contained entry points for specific formats. The cad, urdf, sdf, srdf, and gcode skills each expose thin command-line interfaces that invoke cadpy functionality. For example, skills/cad/scripts/step/cli.py routes CLI arguments to cadpy.api.generate_step, while skills/gcode/scripts/gcode_tool.py handles slicing operations.
Integration Methods
You can adopt text-to-CAD through three primary integration patterns depending on your stack requirements.
Command-Line Integration via Skill CLI
The Skill CLI enables shell-based automation without Python dependencies. Install the tool globally via npm, then invoke specific skills directly from bash scripts or Makefiles.
# Install the skill set
npx skills install earthtojake/text-to-cad
# Generate a STEP file from a prompt
text-to-cad cad "a 50 mm diameter cylinder with a 5 mm fillet" \
--out models/part.step \
--export stl --out models/part.stl
This approach suits CI/CD pipelines and legacy build systems that execute shell commands.
Python API Integration
For data-processing pipelines or Jupyter notebooks, import cadpy directly to build and export geometry programmatically. This method provides granular control over the CadModel instance before serialization.
from pathlib import Path
from cadpy import api as cad
# Instantiate model and define geometry
model = cad.CadModel()
model.box(width=100, height=100, depth=100)
# Export to multiple formats
Path("output/cube.step").write_bytes(model.to_step())
Path("output/cube.glb").write_bytes(model.to_glb())
The Python API supports parametric methods like l_bracket and allows custom assembly hierarchies before calling to_step() or to_stl().
CI/CD Pipeline Integration
Embed text-to-CAD into automated build systems using ephemeral Skill CLI installations. GitHub Actions, GitLab CI, and Jenkins pipelines can install the tool during job execution and upload generated artifacts.
# .github/workflows/cad-generation.yml
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with: {node-version: '20'}
- run: npx skills install earthtojake/text-to-cad
- run: text-to-cad cad "gear assembly with 12 teeth" --out models/gear.step
- uses: actions/upload-artifact@v3
with:
name: cad-assets
path: models/
CAD Viewer for Interactive Preview
The cad-viewer skill launches a local Vite server for immediate visual verification. This component watches the output directory and serves generated GLB, STEP, or STL files at a localhost URL.
npx skills install earthtojake/text-to-cad-viewer
npx skills start cad-viewer --dir $(pwd)/models
Integrate this into local development workflows to validate geometry before committing to version control.
Step-by-Step Implementation Guide
Follow these steps to embed text-to-CAD into your production environment.
-
Install the Skill CLI
Runnpm install -g @skillforge/clior usenpxdirectly to avoid global installation. Executenpx skills install earthtojake/text-to-cadto download binaries into~/.skills/. -
Generate Assets via CLI
Calltext-to-cad cadwith your natural language prompt and desired output paths. Use--exportflags to generate secondary formats like STL or 3MF simultaneously. -
Implement Python Automation (Optional)
For complex logic, create a Python script that importscadpy.api, constructsCadModelinstances, and writes bytes to your asset directory usingPath.write_bytes(). -
Configure CI Integration
Add the installation and generation commands to your pipeline YAML. Ensure subsequent steps reference the output directory containing the generated STEP or URDF files. -
Enable Local Preview
Start the CAD Viewer in development environments to provide engineers immediate visual feedback on generated geometries.
Practical Workflow Examples
Shell-Script Pipeline
Automate parametric part generation and slicing for additive manufacturing.
#!/usr/bin/env bash
set -e
# Generate base geometry
text-to-cad cad "a 30 mm thick plate with two 5 mm holes 10 mm apart" \
--out models/plate.step \
--export stl --out models/plate.stl
# Convert to G-code using printer profile
text-to-cad gcode models/plate.stl \
--profile configs/printer_profile.json \
--out models/plate.gcode
Python-Only Workflow
Create complex assemblies within a Python data pipeline.
from pathlib import Path
from cadpy import api as cad
# Define parametric L-bracket
bracket = cad.CadModel()
bracket.l_bracket(
base_width=80,
base_height=100,
leg_length=150,
thickness=5,
)
# Batch export to required formats
output_dir = Path("models")
output_dir.mkdir(exist_ok=True)
output_dir.joinpath("bracket.step").write_bytes(bracket.to_step())
output_dir.joinpath("bracket.stl").write_bytes(bracket.to_stl())
output_dir.joinpath("bracket.glb").write_bytes(bracket.to_glb())
Integrated CI/CD Configuration
Complete GitHub Actions workflow for automated asset generation on every pull request.
name: Generate CAD Assets
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with: {node-version: '20'}
- name: Install text-to-CAD
run: npx skills install earthtojake/text-to-cad
- name: Generate sphere with fillet
run: |
text-to-cad cad "a 50 mm radius sphere with a 2 mm fillet" \
--out models/sphere.step \
--export stl --out models/sphere.stl
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: cad-assets
path: models/*
Key Source Files and References
Understanding the repository structure helps when debugging or extending functionality.
packages/cadpy/src/cadpy/api.py— Core Python API containingCadModeland export methodsskills/cad/scripts/step/cli.py— CLI entry point for STEP generationskills/gcode/scripts/gcode_tool.py— G-code slicing implementationskills/cad/SKILL.md— Specification for CAD generation capabilitiesskills/urdf/SKILL.md— Documentation for robot description generationskills/gcode/SKILL.md— FDM slicing parameters and usageskills/cad-viewer/SKILL.md— Local preview server configurationREADME.md— High-level installation and quick-start instructions
Summary
- Skill CLI provides shell-based integration for CI/CD and build scripts without requiring Python knowledge
cadpyPython API offers direct access toCadModelconstruction and multi-format export viato_step(),to_stl(), andto_glb()- Modular architecture separates core geometry logic (
packages/cadpy/) from format-specific CLI wrappers (skills/) - CAD Viewer enables immediate visual validation through a localhost server during development
- Supported formats include STEP, STL, 3MF, GLB, URDF, SDF, SRDF, and G-code, covering mechanical CAD and robotics workflows
Frequently Asked Questions
What file formats does text-to-CAD support?
The ecosystem exports to STEP, STL, 3MF, GLB, URDF, SDF, SRDF, and G-code. The cadpy library handles geometric conversions internally, while individual Skill CLI wrappers like cad, urdf, and gcode specialize in specific output pipelines.
Can I use text-to-CAD without installing Node.js permanently?
Yes. While the Skill CLI requires Node.js for installation, you can use npx to run commands without global installation. Alternatively, import the cadpy Python package directly into your scripts if you prefer a pure Python environment, bypassing the CLI entirely.
How does the CAD Viewer integrate with existing project directories?
The CAD Viewer skill starts a local Vite server that watches a specified directory. When you run npx skills start cad-viewer --dir $(pwd)/models, the server serves files from that path and automatically refreshes when new STEP or GLB files appear, providing immediate visual feedback without leaving your development environment.
Is the Python API suitable for real-time parametric modeling?
Yes. The cadpy.api.CadModel class supports methods like box() and l_bracket() that accept dimensional parameters. You can programmatically adjust these values based on external data sources and regenerate exports instantly, making it suitable for automated parametric design workflows.
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 →