Skip to main content

Batch-draw shapes in AutoCAD from a JSON/CSV spec, via pyautocad. Includes a mock backend for testing without AutoCAD.

Project description

cadbatch

Batch-draw shapes (lines, circles, text) in AutoCAD from a simple JSON or CSV spec file, automated with 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

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

Usage

Spec file (shapes.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):

cadbatch shapes.json

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

cadbatch shapes.json --real

Or use it as a library:

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

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

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cadbatch-0.1.0.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cadbatch-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file cadbatch-0.1.0.tar.gz.

File metadata

  • Download URL: cadbatch-0.1.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cadbatch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 063d9e8234c6be7fcd1c85235b92d1c6e16fcba716a11f899797a48a7145090e
MD5 492fca9871936ec43b4088ca7e0053b9
BLAKE2b-256 316b72c74a88b2fe19992110d4f50b0763ad8eabc4c0937827779a4f237c8e64

See more details on using hashes here.

File details

Details for the file cadbatch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: cadbatch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for cadbatch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95d771a4ad20b6060361b6824db4575ba46515ac84a4eb3e09bb0d1c779d2de7
MD5 d71fbee72a981ed3ba67491a2420abe0
BLAKE2b-256 af40b94790c253991c241df9ed84b3a4349f5f26f29e1148a514e2cb1e3b80e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page