Repository navigation
DWG: DraftCraft's own writer for every version; acadrust removed - #16
Merged
Merged
Conversation
Rebrand to DraftCraft™ (brand only)
Builds apps/draftcraft-web with Trunk and publishes it with GitHub Pages' Actions flow, only in withshalom/draftcraft and only from main. Not part of the pull requests sent upstream. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rss9szchwv8emEAdE9m
…web and Linux Logo - crates/ui-egui/src/brand.rs: the app icon (the compass on its blueprint tile) as a texture, decoded once per size, with a DC tile only if it can't be drawn. - The application button shows the logo instead of the DC letters; the Start page and the About window show it beside the name; About adds "DraftCraft and the DraftCraft logo are trademarks of WithShalom Studios." (Italian and Chinese added). The Windows title bar uses the same module. - Web: the logo is the page's favicon and touch icon and sits on the loading screen. Menu bar - Where DraftCraft doesn't draw its own title bar (the web, Linux), the menu bar was drawn after the ribbon, so it sat under it. It is now the top row, laid out like the Windows title bar: the logo, the name, then File … Help, above the application bar and the ribbon. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rss9szchwv8emEAdE9m
…above the ribbon Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rss9szchwv8emEAdE9m
His desktop builds already place the menu bar where he wants it (Windows in DraftCraft's own title bar, macOS in the system menu bar, Linux under the desktop's title bar), so the desktop code goes back to his. Only the web build, which has no title bar of its own, draws the top row (logo, DraftCraft, File … Help) above the ribbon, matching Windows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rss9szchwv8emEAdE9m
# Conflicts: # crates/ui-egui/src/brand.rs # crates/ui-egui/src/window_frame.rs
- The web build's top row draws the full logo (icon and DraftCraft™ wordmark) 24 pt tall, as the Windows title bar does. - manifest.webmanifest: name, standalone display, the app's colours, the 256 and 512 px icons. - sw.js: a small service worker so the browser can install the app and open it offline. It only answers this site's own GET requests: the page from the network first (a new build shows at once), Trunk's hashed script and wasm from the saved copy first, and files of older builds are dropped. Nothing runs while drawing; the canvas and GPU are untouched. - index.html: links the manifest and registers the worker after the page has loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rss9szchwv8emEAdE9m
acadrust already builds for wasm32-unknown-unknown (web-time clocks, sequential fallbacks, file memory-mapping kept native), and the bridge only passes bytes through a Cursor. build.rs and Cargo.toml no longer leave it out on wasm32; FreeBSD aarch64 stays excluded. With no worker started in the web app, DWG work runs in the page, as it does in a library or test. The crate docs now say the catch_unwind guard is native-only: wasm32 aborts on a panic. Ported from withshalom/cadcraft acadrust-web (c2eaa7b), already live on cadcraft.dev. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rsq8SMvTJUJTMsK8dUk
DWG in the web build: build the acadrust bridge for wasm32
…st bridge named acadrust draftcraft-dwg becomes DraftCraft's own DWG codec, from BlackCAD (withshalom/blackcad, MIT OR Apache-2.0, written from the ODA's public DWG specification): - read/: R13 to 2018 and later (except 2007) into the records of the file's objects - write/: AutoCAD 2018 (AC1032) files from records - records/: one plain record per DWG object (BlackCAD's cad-model without its editing API) - bits, crc, lz77: the format's primitives, shared by both The crate still depends on no other workspace crate (layer 0). Nothing calls the new reader yet: draftcraft-io maps its records into the drawing in the next commits. The acadrust bridge, called `native` (it builds on desktop targets), is now `acadrust`, named for what it does: DWG to and from DXF bytes through the acadrust crate, the fallback for what the reader and writer don't cover yet. Callers use draftcraft_dwg::acadrust::…; the cfg that leaves it out is no_acadrust. Lints: wildcard imports expanded, the writer's per-type dispatch split into four functions and the bit-stream round-trip test into two (cognitive complexity). BlackCAD's writer tests compare against cad-dxf output and are left out until the writer is tested against DraftCraft's model. Tests: 92 pass with MI201_CORPUS set (the codec's corpus tests skip without it); 11 ignored as in BlackCAD. clippy -D warnings, layers and the wasm32 check pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rsr8EV2T1Jia8QwNpDr
A DWG reader in draftcraft-io that maps the records draftcraft-dwg's reader decodes straight into the drawing, with no DXF in between: LINE, POINT, CIRCLE, ARC, ELLIPSE, LWPOLYLINE, TEXT, MTEXT, INSERT (without attributes), SOLID, TRACE, 3DFACE, XLINE, RAY, layers, linetypes, text styles, blocks (anonymous ones numbered as AutoCAD numbers them in DXF), paper-space layouts, the main header variables and other applications' extended data. What it leaves out is counted in dwg_read::Coverage. Where a value means the same in DWG and DXF, it uses the DXF reader's own rule: ocs_n, transparency_440, style_font_of (factored out of style_font), dxf_raw's xdata rules, and unescape_unicode (now public in draftcraft-dxf). Opt-in: DRAFTCRAFT_DWG_READER=native|auto|acadrust (default acadrust) and read_dwg_with(bytes, DwgReader). `auto` uses the native reading only when nothing was left out; the default stays acadrust until non-graphic objects are carried into foreign data. Tests (tests/it/dwg_native_read.rs): every mapped type written as DWG 2000–2018, and AutoCAD's MI-201 files R14–2018 (MI201_CORPUS), read identically to the acadrust path, entity by entity; damaged files don't panic. Opening a 200k-entity DWG: 0.57–0.62 s native, 2.1–2.2 s acadrust. roundtrip::handle_limits::dwg_exhausted_handles_are_preserved_or_refused fails as it does on main (acadrust's DWG 2000 writer); nothing here changes the save path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rsr8EV2T1Jia8QwNpDr
docs/dwg.md: how DraftCraft reads DWG (the codec in draftcraft-dwg, the mapping in io, acadrust as the fallback), choosing the reader (DRAFTCRAFT_DWG_READER), what the native reader maps and what it doesn't yet, how to run the fidelity tests (with and without MI201_CORPUS) and the speed measurements. crates/io/examples/dwg_bench.rs: builds a drawing of lines, arcs, circles and text (200,000 entities by default), saves it as DWG 2018 and opens it with both readers, timing each and checking every entity comes out the same. Here: acadrust 2.2–2.3 s, native 0.68–0.77 s, 200,000 of 200,000 identical. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rsr8EV2T1Jia8QwNpDr
Clippy 1.99's chunks_exact_to_as_chunks flags four chunks_exact calls with a constant size (UTF-16 text in xrecords, extended data and linetype shapes, and the R2004 page header mask). as_chunks gives arrays, so the indexing into each chunk goes too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rsr8EV2T1Jia8QwNpDr
In-app update (Update Now), DraftCraft 2.0.1 and 2.0.2, issue templates. No conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67Rsr8EV2T1Jia8QwNpDr
DraftCraft's own DWG reader, straight into the drawing
The build and deploy jobs are guarded by the repository's full name, which still said withshalom/draftcraft. Since the rename to withshalom/draftcraft-app the guard is false, so both jobs are skipped and nothing reaches Pages. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RstbriS77DW7Lyida5H
Brings the fork up to upstream main at 24e7d4f, DraftCraft 2.1.0: PDF underlays and PDFIMPORT, contextual ribbon tabs, dynamic block authoring, DesignCenter, Tool Palettes, Sheet Set Manager, eTransmit, LAYTRANS, LAYWALK, geolocation, point clouds, CUI and saved workspaces, text picking, and the DWG codec as upstream merged it (22ffdfa). The merge had no conflicts. The DWG code (crates/dwg, crates/io/src/dwg_read.rs, docs/dwg.md) was already the same on both sides. What stays the fork's own is the web deploy workflow, the web app's page, manifest and service worker, and the web build's top row in ui-egui. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…ed them The rule said "never commit files produced by AutoCAD", which also ruled out the interchange files themselves. The clean-room rule is about the application software: take no proprietary code or information directly from it. DWG and DXF files are what people exchange, so reading them, testing against them and keeping them in the repository as test drawings is interoperability. A drawing kept here still needs its ATTRIBUTION.md row like any other file asset, and screenshots of AutoCAD stay out. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
Sync with upstream DraftCraft 2.1.0
web-deploy: follow the repository's rename to draftcraft-app
… bed The goal is a DWG reader that decodes each object of a file directly into draftcraft-doc's own types, with no other drawing model and no mapping layer in between. This is its first step: nothing is decoded yet, and every object is accounted for. - draftcraft-dwg: `file::DwgFile` opens a DWG to its parts (version, code page, class list, object map) and lists every object with its handle, type and position. It knows bytes only, no drawing model. - draftcraft-io: `dwg::read` is the new reader. It returns the drawing and `Unread`, the objects it has not put in the drawing, counted by type. With nothing read yet, that is every object of the file. - The MI-201 test drawings: one part saved by AutoCAD in every DWG version, each with AutoCAD's DXF of the same drawing as the reference the reader is compared with as it grows. - Tests: every object of every version is counted, the 2007 container is refused by name, the references read, and damaged files never panic. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
Clean-room rule: DWG and DXF files are allowed, whichever program saved them
DWG read straight into the drawing, step 1: the skeleton and its test bed
Every header variable of a DWG file now goes into the drawing's header, under its DXF name and with its DXF meaning, and is compared with AutoCAD's DXF of the same drawing on every version of the test set. - draftcraft-dwg: `DwgFile::header` returns the variables in file order as plain values, with MEASUREMENT (which DWG keeps in another section) and who last saved the file. - draftcraft-io: `dwg::header` sets them in the drawing. What DWG stores differently is converted: the eight variables packed into one flags word, three variables DWG names differently, the decimal separator, the jog angle, colours, and the two dates, which a DWG from AutoCAD 2000 on holds in universal time. - Variables that name a layer, style, block or UCS wait for the tables: each is counted as unread and left out of the header until then. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
DWG read straight into the drawing, step 2: the header variables
…styles The first tables are decoded field by field straight into the drawing's own types, and compared with AutoCAD's DXF of the same drawing on every version of the test set. - draftcraft-dwg: `DwgFile::read_object` opens one object for reading its fields in the order the format stores them (bits, numbers, text, colours, references, extended data). It holds no drawing model. - draftcraft-io: `dwg::tables` reads application names, text styles, linetypes (with their text and shape elements) and layers (colour, linetype, lineweight, on, frozen, locked, plot, transparency, description) into the drawing. - The header variables that name a layer, a linetype or a text style are now set (CLAYER, CELTYPE, TEXTSTYLE, DIMTXSTY and the dimension linetypes). - Still counted as unread: a layer's plot style, which is named by a dictionary, and the tables of the second half of this step (dimension styles, views, UCSs, viewports). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
… UCSs, viewports The rest of the tables are decoded field by field into the drawing's own types and compared with AutoCAD's DXF on every version of the test set. - Dimension styles: every variable of the record, for R13/R14 and for AutoCAD 2000 and later, set through its DXF group code by the table the DXF reader uses, so a variable means the same from either format. The text style, arrowhead blocks and linetypes are resolved by name. - UCSs, named views and viewport configurations. The first *Active viewport sets the snap and grid variables, as in a DXF. - The header variables that name a dimension style, a UCS or an arrowhead block are now set. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
DWG read straight into the drawing, step 3a: layers, linetypes, text styles
…000 to 2018 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…te as AutoCAD writes them Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…2010, 2013 and 2018 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…AutoCAD's files (work in progress) Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…as AutoCAD writes them in every version Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…five versions Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…multilines, images; saving goes through it Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ctionary, classes for every type written acadrust's reader stopped on our 2004 header: the four shorts (and in 2004 two longs and a bit) after the variables were written as 8 raw zero bytes. They are now fields; the header of each of AutoCAD's files writes back byte for byte up to 2004, check sum included. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…clips, multileader and table styles and dimension associations in every version Multileader styles and dimension associations are AutoCAD's bytes in all six versions of the MI-201 files, table styles up to 2007; the reader takes a multileader style's changed flag before the annotative one, as AutoCAD stores them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tyles from 2010 with suppressed rows, margins and borders, PDF underlays Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erlays, handles kept unique across reopen-and-save A dimension block read from a file keeps its entities' handles, which the previous save numbered above the drawing's own seed; new records now skip them instead of reusing them. A save that would put two objects under one handle (a drawing that has used up its handles) is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…p to AutoCAD 2010 SAT text as the DXF record holds it, in blocks of at most 4096 bytes; binary ACIS from the data store from AutoCAD 2004. AutoCAD 2013 and later keep the shape in the data store section, which is not written yet: those solids are left out and the save note says so, as a DXF of those versions does with SAT text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The writer encodes a dynamic block's evaluation graph and every parameter, grip and action AutoCAD stores (about 40 types), in the layouts AutoCAD's files use. The file declares their classes. The direct reader decodes them back into the DXF groups AutoCAD writes, so a dynamic block survives a DWG save and reopen without acadrust. Tests: every type survives DWG 2000, 2004, 2010, 2013 and 2018 through our reader. acadrust's reader reads each one to its last field. A damaged file doesn't panic. The two dynblock_read DWG tests pass again. Also clears the module's clippy errors (visibility, unused helper). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…r three layouts Before 2010 a visual style holds the properties under codes of their own, opacity and specular negative while switched off, and its name ends with a zero byte; a colour before 2004 is its index alone. A style read in one layout is saved in the layout of the version written, with AutoCAD's own defaults for what the later records add. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 2000 AutoCAD's default materials take the shorter tail of files before 2007, the section and detail view styles get or lose the name and number AutoCAD 2018 added, colours AutoCAD's DXF before 2004 leaves out are its defaults, and the detail view style's fields take the order AutoCAD stores them in. The cell style map a table style keeps before 2010 is written for 2000 to 2007 (its colours take the full form in every version) and is part of the modelled table style when read, as the DXF reader has it. References to objects a version can't hold are dropped before the objects are written, with extension dictionaries left empty by that. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ter keeps it Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, CRC-64 checks) The AutoCAD 2007 file is laid out as AutoCAD lays its own out: file header with check data, page map, data pages, section map, header copy. Pages, map sizes, check data and fill are checked against AutoCAD's own 2007 file of the MI-201 drawing. Saving 2007 no longer goes through acadrust. ATTRIB/ATTDEF keep their position lock in 2007 files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… read-back check The files carry the 256-pixel picture AutoCAD shows in its open dialog (PNG from 2013, an 8-bit bitmap before), the save history dates come from TDUCREATE and TDUUPDATE through chrono, and a file that doesn't read back is never saved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DraftCraft now reads and writes DWG with its own code only. The acadrust dependency, its DXF bridge, the worker process and the DRAFTCRAFT_DWG_WRITER and acadrust reader switches are gone. Tests that compared with acadrust now compare with DraftCraft's DXF reading of the same drawing and inspect the files with the object-records reader, which is independent of the reader that opens files. Fixes found on the way, each with its test: - The read-back check no longer refuses a file whose only entities are ones the version can't hold. - $DIMASSOC and $HIDETEXT are written to DXF and the DWG header, clamped to the values they accept, so the header agrees with the variable dictionary. - Entities without a handle (as a program building a drawing may leave a block's) get one before a DWG save instead of being dropped. - The DWG reader drops DraftCraft's generated arrowhead blocks nothing inserts, as the DXF reader does. NOTICE, docs/dwg.md, docs/dwg-handoff.md, docs/architecture.md and docs/dwg-writer-handoff.md describe the new state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
One byte too many after the code page put 0xFF in the plain header's security flags, and AutoCAD refused every 2007 file as password protected. A test now compares the plain file header with AutoCAD's own file in every version, addresses aside. The AutoCAD fixtures include MI-201, AutoCAD's own DXF saved by DraftCraft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four fixes found by opening DraftCraft's files in AutoCAD 2027 and running AUDIT: - Anonymous blocks are stored unnumbered (*D, *T) and flagged anonymous, as AutoCAD's DWG has them; numbered names made AUDIT report the block records. - Visual styles up to 2013 carry AutoCAD's AcDbSavedByObjectVersion extended data; without it AutoCAD can't read a 2000 or 2004 file's visual styles. - A 2000 file gets an empty VX table (with its extended-data terminator) when the drawing names none; "Missing AcDbVXTable" had the file recovered. - In 2000 files the SEQEND is left out of the entity chain: the last attribute's next link is null, as in AutoCAD's own save of the file. Chained, AUDIT reported "AcDbBlockReference wrong subobject class". Each fix has a regression test. probe_drawing compares the save path (drawing -> records -> DWG) with AutoCAD's DWG of mi201. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
withshalom
approved these changes
Nov 14, 2026
Member
|
This is the solution I was wanting to build. Excellent! I have more advances I'll want to build for DWG handling, but this is beyond what is necessary to resolve the acadrust dependency issue. We have a native DWG reader and writer! Excellent work. |
SkryxDev
added a commit
that referenced
this pull request
Nov 14, 2026
web-deploy.yml: the web branch keeps its own (build the full app and the phone viewer, publish on Vercel). The one main gained with PR #16 is withshalom/draftcraft-app's GitHub Pages deploy, which runs only in that repository. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DraftCraft now writes DWG with its own codec in every version from 2000 to 2018 (R2000, R2004, R2007 with its Reed-Solomon container, R2010, R2013, R2018). acadrust is removed.
What's covered: entities, tables, blocks (including anonymous and dynamic blocks), visual styles in all three layouts, materials, cell style maps, previews, and save dates in AutoCAD's universal time. Each save is read back and checked before it's written.
Checked in AutoCAD 2027 for Mac (November 2026). These files open with no recovery and AUDIT reports 0 errors:
Four fixes got there (last commit):
*D,*T).AcDbSavedByObjectVersionextended data.Each fix has a regression test.
Not done yet
crates/dwg/src/writeis still used bycomposeand can't be removed yet.docs/dwg-writer-handoff.mdhas the details.Test plan
cargo xtask cigates: fmt, clippy, i18n, assets, layers and wasm pass. Tests pass apart from the three that AGENTS.md lists as failing only on macOS.write_dwg_fixtures, opened in AutoCAD 2027, then_AUDITrun on each: 0 errors found, 0 objects deleted.🤖 Generated with Claude Code