The library for the Duc 2D CAD file format
Project description
ducpy
2D CAD File Format
The ducpy package is the official Python implementation of the .duc 2D CAD file format. It is built on top of the duc Rust crate, exposed as the ducpy_native extension. A .duc file is a zlib-compressed SQLite database — ducpy gives you both a high-level builder DSL and direct low-level access to that schema, plus parsing, serialization, and search helpers.
Installation
pip install ducpy
or with uv:
uv add ducpy
Quick start
import ducpy as duc
API overview
ducpy is organised around four conceptual entry points, matching the structure of the full API reference:
Builders API (High-level)
The easy way to build and manage .duc files. Construct elements, apply styles, manage layers, build blocks, and handle document state through the duc.builders module.
See the worked examples:
- Element creation — building rectangles, ellipses, polygons, lines, arrows, text, frames and plots with the fluent builder DSL.
- Mutating elements — updating element properties in place and observing version changes.
- Document elements and model elements — for the higher-level container / model element types.
SQL Builder (Low-level)
A .duc file is a zlib-compressed SQLite database. Use duc.builders.sql_builder (DucSQL) for direct schema access, bulk queries, and low-level manipulation.
See the worked example: SQL Builder — DucSQL.new() to create a .duc from scratch, DucSQL(path) to query an existing one.
Search
Query and search elements and files programmatically through the duc.search API.
File I/O
Read and write .duc files using the duc.parse and duc.serialize modules.
See the worked examples:
- Parsing —
parse_duc/parse_duc_lazy/get_external_file/list_external_files. - Serialization —
serialize_ducfrom builder-created elements. - External files — attaching binary blobs (images, PDFs) to a
.ducdocument.
Documentation
For detailed documentation, including the full API reference, schema specification, and end-to-end examples, see:
- API reference & guides: duc.ducflair.com
- Source-level reference: docs/
- Full example index: docs/examples.rst
Tools
- Playground: Experiment with the
ducformat in a live environment.
Contributing
Feel free to open an issue or contact us at Ducflair Support.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file ducpy-3.4.0.tar.gz.
File metadata
- Download URL: ducpy-3.4.0.tar.gz
- Upload date:
- Size: 123.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4080ea6a2af4334fbdf9f83ffc3c103ddcd4db021526a8b1fb83c4cb2e8c646
|
|
| MD5 |
78e200c5b546ab224f4fa4c0c5f97dda
|
|
| BLAKE2b-256 |
bb02149c4e02b2550babc8812097d1ea09607cdf7891a520143fd46ccd202038
|