Compares 3D CAD models using metrics like IoU and Dice to evaluate generated geometry against reference files.

Install

mkdir -p .claude/skills/model-compare && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/406" && unzip -o skill.zip -d .claude/skills/model-compare && rm skill.zip

Installs to .claude/skills/model-compare

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Compare 3D CAD models using boolean operations (IoU, Dice, precision/recall). Use when evaluating generated models against gold references, diffing CAD revisions, or computing similarity metrics for ML training. Triggers on: model diff, compare models, IoU, intersection over union, model similarity, CAD comparison, STEP diff, 3D evaluation, gold reference, generated model, precision recall 3D.
396 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Computes IoU and Dice similarity scores
  • Calculates volume and surface area ratios
  • Generates precision/recall metrics
  • Visualizes geometric differences

How it works

Runs geometric boolean operations on CAD files to calculate overlap and spatial divergence.

Inputs & outputs

You give it
Reference file path and generated file path
You get back
JSON file with IoU, volume, and bbox metrics

When to use model-compare

  • Evaluate ML-generated 3D models
  • Diff CAD design revisions
  • Compute IoU for 3D generative training
  • Compare 3D mesh and solid model geometry

About this skill

3D Model Comparison Tool

Compare CAD models using boolean operations to compute similarity metrics like IoU, Dice, precision, and recall. Useful for:

  • Evaluating ML-generated models against gold references
  • Comparing revisions of CAD designs
  • Computing metrics for training 3D generative models
  • Visualizing geometric differences

Quick Start

# Compare two STEP files
uvx --from build123d python scripts/model_diff.py reference.step generated.step

# JSON output for training pipelines
uvx --from build123d python scripts/model_diff.py ref.step gen.step --json --no-export

# Demo mode (no files needed)
uvx --from build123d python scripts/model_diff.py --demo

Supported Formats

FormatExtensionNotes
STEP.step, .stpRecommended - full CAD fidelity
BREP.brepOpenCASCADE native format
STL.stlMesh format - may have boolean issues

Output Metrics

Primary Metrics (for ML training)

MetricRangeDescription
IoU (Jaccard)0-1`
Dice (F1)0-1`2
Precision0-1`
Recall0-1`

Diagnostic Metrics

MetricDescription
volume_ratioB/A volume ratio (1.0 = same size)
center_offsetDistance between centers of mass
bbox_iouBounding box IoU (coarse alignment)
size_ratio_x/y/zPer-axis scale comparison
surface_ratioSurface area comparison

Interpretation

The tool provides automatic interpretation:

  • Over-generating: Low precision, high extra geometry
  • Under-generating: Low recall, missing geometry
  • Size issues: Volume ratio far from 1.0
  • Position issues: Large center offset

CLI Options

usage: model_diff.py [-h] [-o OUTPUT_DIR] [--json] [--no-export] [--demo]
                     [reference] [generated]

positional arguments:
  reference          Reference/gold model file (STEP, BREP, or STL)
  generated          Generated/predicted model file to compare

options:
  -o, --output-dir   Output directory for GLB files (default: .)
  --json             Output only JSON metrics (for pipelines)
  --no-export        Skip exporting GLB visualization files
  --demo             Run with built-in demo models

Output Files

When --no-export is not set, produces GLB files for visualization:

FileDescription
diff_reference.glbThe reference model (A)
diff_generated.glbThe generated model (B)
diff_missing.glbGeometry in A but not B (under-generation)
diff_extra.glbGeometry in B but not A (over-generation)
diff_common.glbGeometry in both (correct match)

Example: Training Pipeline Integration

# Batch evaluation
for gen in outputs/*.step; do
    uvx --from build123d python model_diff.py gold.step "$gen" --json --no-export
done | jq -s '{
    avg_iou: (map(.iou) | add / length),
    avg_precision: (map(.precision) | add / length),
    avg_recall: (map(.recall) | add / length)
}'

Example: Loss Function

# In your training code, use metrics for loss:
loss = (
    (1 - metrics['iou']) * 1.0 +           # Primary shape match
    abs(1 - metrics['volume_ratio']) * 0.5 + # Scale accuracy
    metrics['center_offset'] * 0.1           # Position accuracy
)

How It Works

The tool uses boolean operations from OpenCASCADE (via build123d):

Missing  = Reference - Generated  (A - B)
Extra    = Generated - Reference  (B - A)
Common   = Reference & Generated  (A ∩ B)
Union    = Reference + Generated  (A ∪ B)

IoU      = volume(Common) / volume(Union)
Dice     = 2 * volume(Common) / (volume(A) + volume(B))
Precision = volume(Common) / volume(B)
Recall    = volume(Common) / volume(A)

Sample Output

=================================================================
  3D MODEL COMPARISON REPORT
  Reference (A) vs Generated (B)
=================================================================

──────────────────────────── VOLUMES ────────────────────────────
  Reference (A):          51,433.629
  Generated (B):          45,904.426
  Intersection (A∩B):     42,292.031
  Missing (A-B):           9,141.598  (17.8% of A)
  Extra (B-A):             3,612.395  (7.9% of B)

──────────────────────── PRIMARY METRICS ────────────────────────
  IoU (Jaccard):              0.7683  (1.0 = identical)
  Dice (F1):                  0.8690  (1.0 = identical)
  Precision:                  0.9213  (correctness of B)
  Recall:                     0.8223  (coverage of A)

──────────────────────── INTERPRETATION ─────────────────────────
  △ Partial match (IoU > 50%)
  → Under-generating: 17.8% of A is missing
  → Undersized by 10.8%
=================================================================

When not to use it

  • Non-3D geometry tasks
  • Evaluating purely 2D image models

Prerequisites

Build123d libraryPython environment

Limitations

  • Performance issues with high-poly meshes
  • Sensitive to model orientation and scaling

How it compares

It provides quantitative engineering metrics (IoU/Dice) instead of qualitative visual inspection.

Compared to similar skills

model-compare side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
model-compare (this skill)77moReviewAdvanced
cellxgene-census87moReviewAdvanced
tcga-bulk-data-preprocessing-with-omicverse15moNo flagsAdvanced
alterlab-hypogenic01moReviewIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

cellxgene-census

davila7

Query CZ CELLxGENE Census (61M+ cells). Filter by cell type/tissue/disease, retrieve expression data, integrate with scanpy/PyTorch, for population-scale single-cell analysis.

88

tcga-bulk-data-preprocessing-with-omicverse

Starlitnightly

Guide Claude through ingesting TCGA sample sheets, expression archives, and clinical carts into omicverse, initialising survival metadata, and exporting annotated AnnData files.

14

alterlab-hypogenic

AlterLab-IEU

Runs automated LLM-driven hypothesis generation and testing on tabular datasets with HypoGeniC, combining literature insights with data-driven testing. Use when systematically exploring hypotheses about patterns in empirical data (for example deception detection or content analysis). For manual hypo

00

torchdrug

davila7

Graph-based drug discovery toolkit. Molecular property prediction (ADMET), protein modeling, knowledge graph reasoning, molecular generation, retrosynthesis, GNNs (GIN, GAT, SchNet), 40+ datasets, for PyTorch-based ML on molecules, proteins, and biomedical graphs.

326

string-database

davila7

Query STRING API for protein-protein interactions (59M proteins, 20B interactions). Network analysis, GO/KEGG enrichment, interaction discovery, 5000+ species, for systems biology.

217

transformer-lens-interpretability

davila7

Provides guidance for mechanistic interpretability research using TransformerLens to inspect and manipulate transformer internals via HookPoints and activation caching. Use when reverse-engineering model algorithms, studying attention patterns, or performing activation patching experiments.

215

Search skills

Search the agent skills registry