Metadata-Version: 2.4
Name: cadbatch
Version: 0.1.0
Summary: Batch-draw shapes in AutoCAD from a JSON/CSV spec, via pyautocad. Includes a mock backend for testing without AutoCAD.
Author-email: Akash AK <akakash210@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/aakas07/cadbatch
Project-URL: Repository, https://github.com/aakas07/cadbatch
Keywords: autocad,pyautocad,automation,cad,cli
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: autocad
Requires-Dist: pyautocad>=0.2.0; extra == "autocad"
Dynamic: license-file

# cadbatch

Batch-draw shapes (lines, circles, text) in AutoCAD from a simple JSON or CSV
spec file, automated with [pyautocad](https://pypi.org/project/pyautocad/).

Built for repetitive drafting tasks — instead of manually placing dozens of
shapes in AutoCAD, describe them in a spec file and let `cadbatch` draw them
via COM automation.

## Why a mock backend?

AutoCAD automation (via `pyautocad`/COM) only runs on Windows with a licensed
copy of AutoCAD installed. So this package ships a `MockBackend` that records
every draw call in memory — the whole pipeline (spec loading, validation,
batch drawing, CLI) can be built, unit-tested, and demoed on any machine.
Swap to `RealBackend` on a Windows box with AutoCAD to actually draw.

## Install

```bash
pip install cadbatch          # core package, mock mode only
pip install cadbatch[autocad] # + pyautocad, for real AutoCAD drawing (Windows only)
```

## Usage

Spec file (`shapes.json`):

```json
[
  {"shape": "line", "x1": 0, "y1": 0, "x2": 50, "y2": 25},
  {"shape": "circle", "x1": 25, "y1": 12, "radius": 10},
  {"shape": "text", "x1": 0, "y1": 30, "text": "Hello CAD"}
]
```

Run in safe mock mode (no AutoCAD needed):

```bash
cadbatch shapes.json
```

Run against a live AutoCAD instance (Windows, AutoCAD installed and running):

```bash
cadbatch shapes.json --real
```

Or use it as a library:

```python
from cadbatch import load_spec, BatchDrawer, get_backend

specs = load_spec("shapes.json")
drawer = BatchDrawer(get_backend(use_real=False))
drawer.draw_all(specs)
```

## Spec format

| field  | required for   | type  |
|--------|-----------------|-------|
| shape  | all             | `line` \| `circle` \| `text` |
| x1, y1 | all             | float |
| x2, y2 | `line`          | float |
| radius | `circle`        | float |
| text   | `text`          | str   |

CSV files use the same column names (see `examples/`).

## Development

```bash
pip install -e .
python -m unittest discover -s tests -v
```

## License

MIT
