# How to Find Off-the-Shelf STEP Parts (Screws, Bearings, Motors) With text-to-cad

> Easily find off-the-shelf STEP parts like screws, bearings, and motors using text-to-cad. Search, download, and verify hardware STEP files directly from the step.parts catalog API.

- Repository: [earthtojake/text-to-cad](https://github.com/earthtojake/text-to-cad)
- Tags: how-to-guide
- Published: 2026-08-04

---

**The text-to-cad repository provides a step-parts skill that queries the step.parts catalog API to search, download, and verify SHA-256 checksums for standard hardware STEP files, then hands them off to a CAD viewer for immediate inspection.**

Finding accurate CAD models for standard hardware like screws, bearings, and motors is a common bottleneck in mechanical design workflows. The **text-to-cad** open-source project solves this through a modular **step-parts** skill that integrates directly with the public `step.parts` catalog, allowing both manual CLI usage and autonomous agent-driven retrieval of off-the-shelf STEP components.

## How the step-parts Skill Works

The `step-parts` skill follows a deterministic pipeline from natural language request to verified file download. Located under `skills/step-parts/` in the repository, the implementation consists of a manifest descriptor, a Python CLI runtime, and API reference documentation.

### Input Interpretation and Query Building

When the skill receives a request like *"M3 socket head screw 12 mm"*, it constructs a fuzzy query for the Step Parts API endpoint `/v1/parts`. According to [`skills/step-parts/references/step-parts-api.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/step-parts/references/step-parts-api.md), the API tokenizes the query string, requiring all tokens to match against part metadata. The skill supports optional facet filters including `tag`, `category`, `family`, and `standard` to narrow results.

### Search and Disambiguation

The CLI script [`skills/step-parts/scripts/download_step_part.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/step-parts/scripts/download_step_part.py) handles the HTTP request to the catalog. If multiple parts match the query, the skill returns a structured JSON list containing each candidate's `id`, `name`, `standard`, and key attributes. This allows agent systems or human users to select the exact specification required before committing to download.

### Download and Checksum Verification

Once a specific part is selected, the script retrieves the `stepUrl`, streams the binary data to a user-controlled directory, and performs SHA-256 checksum verification if the API provides a hash. This ensures the integrity of mechanical components used in downstream assemblies. The implementation explicitly handles network timeouts, HTTP errors, and filesystem permissions as defined in the runtime logic.

### CAD Viewer Handoff

After successful download and verification, the skill invokes the **CAD Viewer** skill described in [`skills/cad-viewer/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/cad-viewer/SKILL.md). It passes the absolute file path to the viewer, which generates an embeddable URL or launches a browser-based preview of the STEP geometry. This creates a seamless bridge between hardware sourcing and design validation.

## Searching and Downloading STEP Files via CLI

The [`download_step_part.py`](https://github.com/earthtojake/text-to-cad/blob/main/download_step_part.py) script operates as a standalone utility suitable for shell scripts, CI pipelines, or direct terminal use.

### Search Without Downloading

To preview available matches for a hardware component without fetching files:

```bash
python skills/step-parts/scripts/download_step_part.py "M3 socket head 12" --limit 5

```

This outputs a compact JSON array of up to five candidates, including part IDs and standard references, making it easy to pipe into `jq` or other filtering tools.

### Download by Fuzzy Query

To automatically select and download the top-ranked result:

```bash
python skills/step-parts/scripts/download_step_part.py "bearing 608zz" --download

```

The script stores the file in the system temporary directory, verifies the SHA-256 checksum, and returns a JSON payload containing the local path, part ID, and source URLs.

### Download by Exact Catalog ID

For reproducible builds requiring specific standards, use the `--id` flag to bypass fuzzy matching:

```bash
python skills/step-parts/scripts/download_step_part.py \
  --id iso4762_socket_head_cap_screw_m3x12 \
  --download \
  --out-dir ./parts

```

This guarantees retrieval of the exact ISO 4762 specification, storing it as `./parts/iso4762_socket_head_cap_screw_m3x12.step`.

## Agent-Driven Retrieval Workflows

The text-to-cad architecture supports autonomous agents through structured JSON actions. The **step-parts** skill exposes two primary actions: `step-parts.search` and `step-parts.download`.

An OpenAI-compatible agent might execute the following sequence:

1. **Search the catalog:**

```json
{
  "action": "step-parts.search",
  "query": "M3 socket head 12"
}

```

2. **Select and download:**

```json
{
  "action": "step-parts.download",
  "part_id": "iso4762_socket_head_cap_screw_m3x12",
  "download": true,
  "out_dir": "/tmp/cad_parts"
}

```

3. **Trigger viewer preview:**

```json
{
  "action": "cad-viewer.open",
  "path": "/tmp/cad_parts/iso4762_socket_head_cap_screw_m3x12.step"
}

```

The repository's [`AGENTS.md`](https://github.com/earthtojake/text-to-cad/blob/main/AGENTS.md) file defines the orchestration rules mapping these JSON actions to the underlying Python CLI, enabling integration with LangChain, AutoGPT, or custom agent runtimes.

## Summary

- The **step-parts** skill in `earthtojake/text-to-cad` provides programmatic access to the `step.parts` catalog for sourcing standard hardware.
- **[`download_step_part.py`](https://github.com/earthtojake/text-to-cad/blob/main/download_step_part.py)** implements fuzzy search, exact ID retrieval, SHA-256 verification, and configurable output directories.
- The API supports facet filters (`standard`, `category`, `family`) to disambiguate between similar mechanical components.
- Successful downloads automatically trigger the **CAD Viewer** skill for immediate geometry inspection.
- Both manual CLI usage and autonomous agent workflows are fully supported through JSON action schemas.

## Frequently Asked Questions

### How does text-to-cad verify the integrity of downloaded STEP files?

According to the implementation in [`skills/step-parts/scripts/download_step_part.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/step-parts/scripts/download_step_part.py), the script extracts the SHA-256 checksum from the API response metadata when available, computes the hash of the downloaded binary stream, and validates the match before writing the final file to disk. If checksums mismatch or the API omits the hash, the script logs a warning but preserves the file for manual inspection.

### Can I use the step-parts skill without installing the full text-to-cad framework?

Yes. The [`download_step_part.py`](https://github.com/earthtojake/text-to-cad/blob/main/download_step_part.py) script is self-contained and requires only standard Python libraries and network access to `api.step.parts`. You can run it directly from the cloned repository without configuring the broader skill registry or agent orchestration layers, making it suitable for lightweight shell scripting.

### What standards are supported for screws and bearings in the step.parts catalog?

The catalog referenced by [`skills/step-parts/references/step-parts-api.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/step-parts/references/step-parts-api.md) includes major mechanical standards such as ISO (e.g., ISO 4762 for socket head cap screws), DIN, ANSI, and JIS specifications. The `standard` facet filter allows you to constrain searches to specific regulatory frameworks, ensuring retrieved models match your engineering documentation requirements.

### How does the CAD Viewer skill handle the downloaded STEP files?

As documented in [`skills/cad-viewer/SKILL.md`](https://github.com/earthtojake/text-to-cad/blob/main/skills/cad-viewer/SKILL.md), the viewer skill accepts an absolute file path from the step-parts skill, loads the STEP geometry into a browser-based rendering engine, and generates a shareable URL or local preview window. This handoff occurs automatically when the `--download` flag is used, or can be triggered manually via the `cad-viewer.open` action with the path parameter.