← Files ScoptureARCHIVED FILE

skills/duc/docs/python/overview.md

1.64 KB · Nov 16, 2026 · 12:40 UTC

↓ Download file

See the change to this file →

# Python (ducpy) (/docs/python/overview)



## Overview [#overview]

`ducpy` is the official Python SDK for parsing, creating, and manipulating `.duc` files.

***

## Dual API Architecture [#dual-api-architecture]

`ducpy` provides two complementary approaches for working with `.duc` CAD files:

| API Module                                  | Purpose                                                                   | Best for                                                |
| ------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------- |
| **Builders DSL** (`ducpy.builders`)         | Fluent, type-safe Python builder classes for elements, styles, and states | Constructing elements and documents programmatically    |
| **`DucSQL`** (`ducpy.builders.sql_builder`) | Direct SQLite database connection and SQL query execution                 | Batch inserts, direct schema introspection, FTS queries |

***

## Package Architecture [#package-architecture]

* `ducpy.builders`: Fluent builder classes (`ElementBuilder`, style generators).
* `ducpy.builders.sql_builder`: `DucSQL` class for raw SQLite connections and migrations.
* `ducpy.classes`: Dataclass definitions matching the relational database schema.
* `ducpy.enums`: Python enum constants matching `.duc` integer schema codes (`LINE_HEAD`, `TEXT_ALIGN`, `STROKE_PLACEMENT`, etc.).
* `ducpy.parse`: Path-based drawing-state parsing plus streamed external-file, checkpoint, and delta payload access.
* `ducpy.serialize`: Serialization utilities that write `.duc` files and return their output paths.

SHA-256: d7bb05a23b548a918c3efa675e22e48800624c3b33ae791ebb984f56a2b8b757