# Where to Find Text-to-CAD Usage Examples in the earthtojake/text-to-cad Repository

> Explore text-to-CAD usage examples in the earthtojake/text-to-cad repository. Find detailed guides in README files and skill documentation for URDF and CAD formats.

- Repository: [earthtojake/text-to-cad](https://github.com/earthtojake/text-to-cad)
- Tags: getting-started
- Published: 2026-07-24

---

**The earthtojake/text-to-cad repository maintains canonical text-to-CAD usage examples in [`skills/sdf/references/examples.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/sdf/references/examples.md), [`packages/implicitjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/implicitjs/README.md), and the individual skill documentation files for URDF and CAD formats.**

The earthtojake/text-to-cad project provides self-contained example scripts demonstrating how to generate common CAD description formats including SDF, URDF, STEP, and implicit-JS models. These examples serve as the primary reference for understanding text-to-CAD usage patterns and are continuously updated alongside the CLI tools. Whether you are building robotic simulation descriptions or procedural 3D models, the repository contains runnable code snippets that illustrate both low-level XML construction and high-level API usage.

## SDF Examples: Raw XML and Helper API

The SDF (Simulation Description Format) skill documentation in [`skills/sdf/references/examples.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/sdf/references/examples.md) contains two distinct approaches for generating SDF files programmatically.

### Minimal SDF with ElementTree

For direct control over XML structure, the repository demonstrates raw `xml.etree.ElementTree` usage. This approach constructs SDF models without external dependencies beyond Python's standard library.

```python
import xml.etree.ElementTree as ET

def text(parent, tag, value, attrib=None):
    child = ET.SubElement(parent, tag, attrib or {})
    child.text = str(value)
    return child

def gen_sdf():
    sdf = ET.Element("sdf", {"version": "1.12"})
    model = ET.SubElement(sdf, "model", {"name": "calibration_box"})
    text(model, "pose", "0 0 0 0 0 0", {"relative_to": "world"})
    # … additional link / visual / collision / inertial definitions …

    return {"xml": sdf, "assumptions": ["Box inertia uses a uniform-density primitive approximation."]}

```

*(Source: [`skills/sdf/references/examples.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/sdf/references/examples.md), lines 7-47)*

### High-Level SDF Builder API

The preferred method for complex models uses the `sdf.builder` module, which provides semantic helper functions for links, joints, and inertial properties.

```python
from sdf.builder import (
    box, collision, inertial, joint, link, model, pose, sdf_root, visual,
)

BASE_MASS_KG = 2.0
ARM_MASS_KG = 0.5

def gen_sdf():
    sdf = sdf_root("1.12")
    robot = model(sdf, "two_link_demo")
    pose(robot, relative_to="world")

    base = link(robot, "base_link")
    box(visual(base, "base_visual"), (0.4, 0.3, 0.1))
    box(collision(base, "base_collision"), (0.4, 0.3, 0.1))
    inertial(base, BASE_MASS_KG, (0.02, 0.03, 0.04, 0, 0, 0))

    arm = link(robot, "arm_link")
    box(visual(arm, "arm_visual"), (0.3, 0.05, 0.05))
    box(collision(arm, "arm_collision"), (0.3, 0.05, 0.05))
    inertial(arm, ARM_MASS_KG, (0.001, 0.004, 0.004, 0, 0, 0))

    joint(robot, "shoulder_pan", "revolute", "base_link", "arm_link",
          axis_xyz=(0, 0, 1), axis_expressed_in="base_link")
    return {"xml": sdf, "assumptions": ["Primitive inertials are approximate placeholders."]}

```

*(Source: [`skills/sdf/references/examples.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/sdf/references/examples.md), lines 76-128)*

## Implicit-JS Examples for JavaScript CAD Models

The `implicitjs` package demonstrates text-to-CAD usage for implicit surface modeling through JavaScript. The canonical example resides in [`examples/model.implicit.js`](https://github.com/earthtojake/text-to-cad/blob/main/examples/model.implicit.js) and showcases how to define primitive shapes and boolean operations.

```javascript
// examples/model.implicit.js
import { implicit_sphere, implicit_box_centered, implicit_union_round } from "implicitjs";

export default function scene() {
  const sphere = implicit_sphere([0, 0, 0], 0.5);
  const box = implicit_box_centered([0, 0, 0.75], [0.3, 0.3, 0.3]);
  return implicit_union_round([sphere, box], 0.1);
}

```

*(Source: [`packages/implicitjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/implicitjs/README.md) references [`examples/model.implicit.js`](https://github.com/earthtojake/text-to-cad/blob/main/examples/model.implicit.js))*

### CLI Commands for Implicit-JS

The [`packages/implicitjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/implicitjs/README.md) file documents how to execute these examples using npm scripts:

```bash

# Render a snapshot

npm --prefix packages/implicitjs run snapshot -- --input examples/model.implicit.js --output /tmp/model.png

# Export to GLB, STL, or 3MF

npm --prefix packages/implicitjs run export -- --input examples/model.implicit.js --format glb --output /tmp/model.glb

```

## URDF and CAD Skill Documentation

Beyond SDF and implicit-JS, the repository maintains dedicated skill documentation for robotics and mechanical CAD workflows.

- **URDF examples**: The [`skills/urdf/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/urdf/SKILL.md) file contains CLI entry points and references example sections for generating Unified Robot Description Format files.
- **CAD examples**: The [`skills/cad/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/cad/SKILL.md) file covers STEP file generation and build123d integration, providing selector syntax and workflow examples for mechanical CAD.

Both files follow the same pattern as the SDF documentation, listing `python scripts/<skill> …` CLI patterns and linking to runnable code samples.

## Summary

- **SDF examples** reside in [`skills/sdf/references/examples.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/sdf/references/examples.md), offering both raw `xml.etree.ElementTree` and high-level `sdf.builder` API approaches.
- **Implicit-JS examples** are located in [`packages/implicitjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/implicitjs/README.md) and [`examples/model.implicit.js`](https://github.com/earthtojake/text-to-cad/blob/main/examples/model.implicit.js), demonstrating JavaScript-based implicit surface modeling with CLI snapshot and export capabilities.
- **URDF and CAD skill docs** in [`skills/urdf/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/urdf/SKILL.md) and [`skills/cad/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/cad/SKILL.md) provide format-specific entry points and workflow examples.
- All examples are self-contained and synchronized with the repository's CLI tools, ensuring they reflect current text-to-CAD usage patterns.

## Frequently Asked Questions

### Where are the official text-to-CAD usage examples located?

The canonical examples are distributed across three main locations: [`skills/sdf/references/examples.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/sdf/references/examples.md) for simulation descriptions, [`packages/implicitjs/README.md`](https://github.com/earthtojake/text-to-cad/blob/main/packages/implicitjs/README.md) for JavaScript implicit modeling, and the individual [`SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/SKILL.md) files within `skills/urdf/` and `skills/cad/` for robotics and mechanical CAD formats.

### What formats do the text-to-CAD examples support?

The repository provides working examples for SDF (Simulation Description Format), URDF (Unified Robot Description Format), STEP/CAD files via build123d, and implicit-JS models for procedural 3D generation. Each format has dedicated documentation showing both programmatic generation and CLI usage.

### How do I run the implicit-JS examples?

Navigate to the `packages/implicitjs` directory and use npm scripts. For example, run `npm run snapshot -- --input examples/model.implicit.js --output /tmp/model.png` to render a preview, or `npm run export -- --input examples/model.implicit.js --format glb --output /tmp/model.glb` to generate mesh files in GLB, STL, or 3MF formats.

### What's the difference between the raw ET and SDF helper API approaches?

The raw `xml.etree.ElementTree` approach provides direct XML manipulation using Python's standard library, suitable for minimal dependencies. The **SDF helper API** (`sdf.builder`) offers semantic abstractions like `link()`, `joint()`, and `inertial()` functions that reduce boilerplate and enforce schema consistency for complex robotic models.