forked from 1b-agent/opencadstudio-upstream
feat(python): text and dimension styles (doc.text_styles, doc.dim_styles)
Extends TableOperation with text style create/modify, dimension style create/modify (DimStyle fields as a validated JSON object), rename, delete and set-current. Reuses OCS's style in-use scan and reference-following rename (four style_ops methods widened to pub(super)); a renamed text style also updates dimension styles that name it. Real-IPC audit with DWG/DXF persistence and undo, IPC and Python unit tests, docs. Four cadcodec findings are pinned by canaries. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
1 parent
b7b6e2cef5
commit
aaea15e4ef
11 files changed
+894
-8
No files matched your search
@@ -195,3 +195,17 @@ These are format constraints or OCS-side issues, not reader bugs:
|
||||
- **Spline weights in DXF** were briefly suspected but are correct: the writer
|
||||
emits group 41 only when `flags.rational` is set, so the host must set that
|
||||
flag when weights are present (fixed in OCS).
|
||||
|
||||
### Text and dimension style findings (2026-09-21, not filed)
|
||||
|
||||
Found by `audit_python_text_and_dim_styles_over_real_ipc`; each is pinned by a canary.
|
||||
|
||||
- **`STYLE` generation flags:** the DXF writer hard-codes group 71 to 0, so a text
|
||||
style's `flags.backward` and `flags.upside_down` are lost on every DXF save (DWG keeps them).
|
||||
- **`STYLE` oblique angle units:** group 50 is written and read as the raw radian value, while DXF
|
||||
defines it in degrees; it round-trips inside cadcodec but AutoCAD would read 15 degrees as 0.26.
|
||||
DWG stores radians correctly.
|
||||
- **`DIMSTYLE` text style name:** the DXF reader keeps only the text-style handle (group 340) and never
|
||||
resolves `dimtxsty` from it, so the name reopens as `Standard` (the handle is right; DWG resolves both).
|
||||
- **`TextStyle::true_type_font`** is never written or read by either codec, so it lives only in memory.
|
||||
|
||||
@@ -200,3 +200,16 @@ nothing changes. Python: `ocs.active_document.layers` (`create`, `modify`, `rena
|
||||
(19 refusals, live/DWG/DXF persistence of colour, lineweight, transparency, flags, linetype,
|
||||
description, rename following entities, `erase_objects` and one-step undo), an IPC round-trip test and a
|
||||
Python unit test. Next: text and dimension styles, linetypes, blocks, layouts; then headless commands.
|
||||
|
||||
### 2026-09-21: text and dimension styles (`doc.text_styles`, `doc.dim_styles`)
|
||||
|
||||
`TableOperation` grew `TextStyleCreate/Modify`, `DimStyleCreate/Modify` (DimStyle fields travel as a JSON
|
||||
object, so all 88 are settable with host validation; handles, xref fields and the name are refused),
|
||||
`StyleRename`, `StyleDelete`, `StyleSetCurrent`. The host reuses OCS's own style machinery (in-use scan,
|
||||
reference-following rename) by widening four `style_ops` methods to `pub(super)`, and additionally makes a
|
||||
renamed text style's name follow into dimension styles. Style operations require the active tab.
|
||||
Evidence: `audit_python_text_and_dim_styles_over_real_ipc` (26 refusals, live/DWG/DXF persistence, copy
|
||||
semantics, rename following references, current/delete guards, five-step undo), IPC round-trip and Python unit
|
||||
tests. Four cadcodec findings (STYLE flags and oblique units, DIMSTYLE name, `true_type_font`) are pinned by
|
||||
canaries and listed in `cadcodec-reader-gaps.md`. Next: linetypes, blocks, layouts; then headless commands.
|
||||
|
||||
Reference in new issue
Block a user