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

The earthtojake/text-to-cad repository maintains canonical text-to-CAD usage examples in skills/sdf/references/examples.md, 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 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.

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, 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.

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, 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 and showcases how to define primitive shapes and boolean operations.

// 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 references examples/model.implicit.js)

CLI Commands for Implicit-JS

The packages/implicitjs/README.md file documents how to execute these examples using npm scripts:


# 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 file contains CLI entry points and references example sections for generating Unified Robot Description Format files.
  • CAD examples: The 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

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 for simulation descriptions, packages/implicitjs/README.md for JavaScript implicit modeling, and the individual 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.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →