# SendCutSend Skill Validation for DXF and STEP Files: Technical Implementation Guide

> Learn how SendCutSend validates DXF and STEP files using a three-stage pipeline. This guide details checks for file sanity, structure, geometry, and compliance with cadpy_metadata.

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

---

**The SendCutSend skill validates DXF and STEP files through a three-stage pipeline that checks file-type sanity, structural integrity, geometric correctness, and downstream compliance using the `cadpy_metadata` package before dispatching to cutter services.**

The **text-to-cad** repository implements a modular, skill-driven framework that converts textual prompts into manufacturable CAD artifacts. The **SendCutSend** skill serves as a critical quality gate, performing rigorous validation on generated DXF and STEP files to ensure they meet structural and geometric requirements before reaching downstream cutting services. This validation prevents malformed geometry from reaching physical manufacturing tools, reducing material waste and production errors.

## Three-Stage Validation Workflow

The SendCutSend skill processes CAD files through a rigorous workflow that isolates generation from validation:

1. **Generation**: Upstream skills (such as those in [`skills/urdf/scripts/urdf/source.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/urdf/scripts/urdf/source.py)) emit DXF or STEP files to the `models/` directory.

2. **Validation**: The skill invokes the validation engine located in [`packages/cadpy_metadata/src/cadpy_metadata/generator.py`](https://github.com/earthtojake/text-to-cad/blob/main/packages/cadpy_metadata/src/cadpy_metadata/generator.py) to execute comprehensive checks on file integrity and geometry.

3. **Dispatch**: Upon passing all checks, files proceed to cutter services via CLI handlers (such as [`skills/urdf/scripts/urdf/cli.py`](https://github.com/earthtojake/text-to-cad/blob/main/skills/urdf/scripts/urdf/cli.py)), while failures trigger detailed error reports enabling rapid prompt iteration.

## Core Validation Checks

The validation logic resides in the reusable `cadpy_metadata` package, specifically within [`generator.py`](https://github.com/earthtojake/text-to-cad/blob/main/generator.py). This dependency-free Python helper can be vendored into any skill without pulling in heavyweight libraries. The `validate_cad_file()` function performs four categories of checks:

- **File-type sanity**: Verification of correct MIME types and proper file extensions to ensure the parser receives expected input formats.

- **Structural integrity**: Validation of closed-loop polylines for DXF files and valid topological structures for STEP files, ensuring the geometry is manifold and manufacturable.

- **Geometric sanity**: Detection of self-intersections, tolerance checks, and dimensional validation to prevent impossible geometries from reaching production.

- **Downstream compliance**: Verification of printable size limits, axis alignment, and other manufacturing constraints specific to CNC cutting and laser cutting workflows.

Under the hood, the validation leverages open-source parsers including **`ezdxf`** for DXF files and **`pythonOCC`** for STEP files, providing robust geometric analysis without vendor lock-in. The repository’s CI pipeline validates this logic through [`tests/python/packages/cadpy_metadata/test_generation_status.py`](https://github.com/earthtojake/text-to-cad/blob/main/tests/python/packages/cadpy_metadata/test_generation_status.py), ensuring consistent behavior across platform updates.

## Programmatic Usage

You can invoke the SendCutSend validation directly from Python scripts or via the skill’s CLI interface.

### Python API

The `validate_cad_file()` function returns a tuple containing a boolean validity flag and a list of diagnostic messages:

```python
from cadpy_metadata.generator import validate_cad_file

# Path to a generated DXF or STEP file

cad_path = "models/my_part.dxf"

# Returns a tuple (is_valid, messages)

valid, messages = validate_cad_file(cad_path)

if valid:
    print("✅ Validation succeeded – ready for Send Cut Send.")
else:
    print("❌ Validation failed:")
    for m in messages:
        print("   -", m)

```

### Command Line Interface

The skill’s CLI automatically invokes validation before dispatch:

```bash

# Run the skill’s CLI; it will automatically invoke validation

python -m skills.urdf.scripts.urdf.cli \
    --input models/my_part.step \
    --action send-cut-send

```

The CLI prints a human-readable summary of the validation outcome and forwards valid files to the configured cutter endpoint.

## Architectural Benefits

The SendCutSend skill follows the repository’s strict architectural guidelines to ensure maintainability:

- **Isolation**: All validation logic lives in `packages/cadpy_metadata`, preventing code leakage between skills and the repository root.

- **Reusability**: The same metadata generator is used by multiple skills (URDF, SRDF, DXF/STEP), ensuring a single source-of-truth for validation rules.

- **Extensibility**: New file formats can be added by extending the validation registry in [`generator.py`](https://github.com/earthtojake/text-to-cad/blob/main/generator.py); the skill’s CLI automatically discovers them via entry-point registration.

## Summary

- The SendCutSend skill validates DXF and STEP files through a three-stage pipeline: Generation, Validation, and Dispatch.
- Core validation logic resides in [`packages/cadpy_metadata/src/cadpy_metadata/generator.py`](https://github.com/earthtojake/text-to-cad/blob/main/packages/cadpy_metadata/src/cadpy_metadata/generator.py) and is accessed via the `validate_cad_file()` function.
- Four categories of checks ensure file-type sanity, structural integrity, geometric correctness, and downstream manufacturing compliance.
- The system utilizes open-source parsers `ezdxf` for DXF and `pythonOCC` for STEP files to perform geometric analysis.

## Frequently Asked Questions

### What specific validation checks does the SendCutSend skill perform on DXF and STEP files?

The skill executes four categories of validation: file-type sanity (MIME types and extensions), structural integrity (closed-loop polylines for DXF, valid topology for STEP), geometric sanity (self-intersection detection and tolerance checks), and downstream compliance (printable size limits and axis alignment). These checks are implemented as pure-Python utilities in the `cadpy_metadata` package.

### Where is the SendCutSend validation logic implemented in the text-to-cad repository?

The core validation engine resides in [`packages/cadpy_metadata/src/cadpy_metadata/generator.py`](https://github.com/earthtojake/text-to-cad/blob/main/packages/cadpy_metadata/src/cadpy_metadata/generator.py), which provides a dependency-free Python package that any skill can import without heavy library dependencies. This isolation ensures validation rules remain consistent across the URDF, SRDF, and DXF/STEP processing skills.

### How does the SendCutSend skill handle validation failures?

When `validate_cad_file()` returns `is_valid=False`, the skill generates a detailed error report containing specific failure messages for each check that failed. This report is returned to the user or calling process, enabling rapid iteration on the original text prompt to correct geometry issues before resubmission.

### Which open-source libraries does the SendCutSend skill use for parsing CAD files?

The validation layer leverages **`ezdxf`** for parsing DXF files and **`pythonOCC`** for STEP file processing. These libraries provide robust geometric analysis capabilities including topology verification and intersection detection without requiring proprietary CAD software licenses.