Metadata-Version: 2.4
Name: cad-3dto2d
Version: 0.3.0
Summary: Add your description here
Author-email: neka-nat <nekanat.stock@gmail.com>
License-File: LICENSE
Requires-Python: >=3.12
Requires-Dist: build123d==0.8.0
Requires-Dist: cadquery-ocp<7.8,>=7.7.0a0
Requires-Dist: ezdxf>=1.2.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: pyyaml>=6.0
Requires-Dist: rlpycairo>=0.3.0
Requires-Dist: svglib>=1.5.1
Requires-Dist: tqdm>=4.67.3
Requires-Dist: vtk>=9.5.2
Description-Content-Type: text/markdown

# 2D CAD Drawing generation from 3D CAD models

This tool is used to generate 2D CAD drawings from 3D CAD models.

## Installation

Install the package from PyPI:

```bash
pip install cad-3dto2d
```

Or install the package from the source code:

```bash
git clone https://github.com/neka-nat/cad-3dto2d.git
cd cad-3dto2d
uv sync
```

## Usage

```
python scripts/gen2d.py --step_file </path/to/step_file> --template A4_LandscapeParam --add_dimensions
```

Batch generation for machine-learning datasets (random template/style/scale/layout):

```bash
python scripts/gen2d_batch_random.py \
  --input_dir path/to/3d_models_dir/ \
  --output_dir path/to/output_dir/ \
  --recursive \
  --variants-per-step 3 \
  --random-side-position \
  --random-top-position \
  --workers 4 \
  --layout-scale-min 30 \
  --layout-scale-max 70 \
  --layout-offset-x-min -20 \
  --layout-offset-x-max 20 \
  --layout-offset-y-min -20 \
  --layout-offset-y-max 20 \
  --seed 42
```

If you do not need template-based layout alignment, add `--no-use-template-layout` for faster generation.

## Demo

### Original 3D model (Flange)
![3d_flange](assets/simple_flange_3d.png)

### Generated 2D drawing (Flange)
![2d_flange](assets/simple_flange_2d.png)

### Original 3D model (Lego Block)
![3d_lego_block](assets/lego_block_3d.png)

### Generated 2D drawing (Lego Block)
![2d_lego_block](assets/lego_block_2d.png)
