Repository navigation
DWG Support - #15
Closed
withshalom wants to merge 78 commits into
Closed
DWG Support#15withshalom wants to merge 78 commits into
withshalom wants to merge 78 commits into
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
An example that reads DWG files with acadrust disabled and says where the direct reader differs or breaks: - AutoCAD's files: the direct reader against acadrust (entities per type and space, layers, blocks, layouts), and direct read -> DXF -> read the same again; - DraftCraft's drawings (DXF given): saved as DWG in every version and read back, every entity compared with the drawing saved; - --stress <case> <n> [version]: drawings of many entities (mixed, one long polyline, a hatch of many loops, many layers or blocks, long text, a large table, deep block nesting), with sizes, times and peak memory. cargo run --release -p draftcraft-io --example direct_sweep -- out/ files... cargo run --release -p draftcraft-io --example direct_sweep -- --stress mixed 100000 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
The page compression's far copies are `0001HLLL`, as in LZO: H adds 0x4000 to the distance and LLL is the length less two (0: a count follows). The decoder read all four low bits as the length and ignored H, so 0x18-0x1F decoded wrong. They only appear more than 0x8000 bytes back, which a data page (at most 0x7400) never reaches but a large system page does: a 2004-and-later drawing whose section or page map passes about 48 KB (a 32 MB file of 600 000 entities written by acadrust) was refused with "copy of 4 bytes overflows page size". AutoCAD's MI-201 files are too small to show it. Tests: hand-made streams with 0x1A (short) and 0x18 (with a count) far copies, which fail on the old reading, and an unchanged 0x15. The stress drawings of 600 000 and 1 000 000 entities now read whole. direct_sweep: on a difference, says whether acadrust reads the same file right (the reader's fault) or not (the file's), and where the two readings part; on a failure, whether acadrust reads the file and, with SWEEP_KEEP=<dir>, keeps it; peak memory per case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…ogram's DXF - write_dwg_fixtures (ignored test): every step's test drawing as DWG in every version, to DWG_FIXTURES_OUT, for other programs to read. - direct_sweep --vs-dxf <dwg> <dxf>: the direct reading of a DWG against another program's DXF of the same file (BlackCAD's `cad dxf`, AutoCAD's SAVEAS), entity by entity. - direct_sweep --stress keeps each DWG with SWEEP_SAVE=<dir>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
Two readings of the same drawing through different formats differ in the last digits of a value written in degrees and read in radians (an arc's start angle 0.7853981633974623 against ...483 through BlackCAD's DXF): entities are compared as values, numbers within 1e-9 of their size, not as text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…ct reader - Table records go into the drawing's lists through a name index made once per table, and the layers the drawing has are kept in a set while entities are placed: each was a search of the whole list per record or entity, so 100 000 layers took 136 s. - direct_sweep --read <files>: only the direct reading, with its time and peak memory (SWEEP_READER=acadrust for acadrust's). - docs/dwg.md rewritten for the direct reader: the layout, choosing the reader, what each step reads, the plan to full fidelity with what is open or unconfirmed, the tests (AutoCAD's files, every type in every version, damaged files, the sweep, the stress drawings, BlackCAD), every bug the testing found with its fix, and the speed against acadrust. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…de the reader Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…ery code page Found by comparing AutoCAD's own sample drawings (ACadSharp's samples, saved by AutoCAD in every version) with AutoCAD's DXF of the same drawing: - A colour book colour (ENC flags 0xC000) stores no true colour after its flags: the codec read 32 bits that aren't there and lost the entity (CIRCLE 99F, every version from 2004). The colour is the DBCOLOR object's the entity names; its CMC names give the 430 group (book$colour), kept as the DXF reader keeps it. Layers keep their colour book name too. - A file saved as 2000 keeps later properties in ACAD extended data: RTTcAl (true colour and colour book) and RTMaterial. AutoCAD's DXF of the file has them as the properties, so the reader takes the colour and leaves both sequences out of the extended data kept. The colour applies only while the entity's index is the one AutoCAD saved with it. - Text in any of the DWG code pages (1 to 44), Unicode escapes and surrogate pairs, through a decoding hook the reader gives the codec. - TEXT: an alignment point the file leaves out is (0,0), as R14 stores it. - DIMSTYLE: the newer variables DraftCraft keeps in DIMVARS extended data for older versions are read back. - STYLE: the shape-file bit comes before the vertical bit (AutoCAD's files). - direct_sweep --deep: every difference between a DWG's direct reading and the DXF of the same drawing. Tests: the codec's ENC and CMC rules, the round-trip sequences, and AutoCAD's samples when DRAFTCRAFT_DWG_SAMPLES names their folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…AutoCAD's DXF has them Compared with AutoCAD's DXF of the same drawings (ACadSharp's samples, saved by AutoCAD in every version): - LEADER: a straight leader to text whose last segment is more than 15 degrees off the text's direction ends in a hook line, the arrow size long. The DWG leaves it out; AutoCAD's DXF lists its first point before the last vertex, which is how the drawing holds a leader (LEADER 512: three vertices in the DWG, four in the DXF). - WIPEOUT and IMAGE: a polygon clip boundary is closed, its first vertex again at the end, as AutoCAD's DXF lists it (the DWG stores it open). - TOLERANCE: a line break of the frame is ^J, as in AutoCAD's DXF and the drawing's GD&T text; the DWG stores the character, which a DXF save turned into a space. - SPLINE, AutoCAD 2013 and later: a spline with fit data stores its end derivatives with their length and the knot spacing; the control points are now AutoCAD's (Spline::fit_with_derivatives: a third of the derivative from each end for two fit points, as AutoCAD's DXF has them). - ACAD_SPLINE_DATA is AutoCAD's round-trip data of an older version's file: not kept as extended data (AutoCAD's DXF has none of it). Tests: the hook, frame and clip rules with AutoCAD's numbers, the fit with derivatives against AutoCAD's control points, and AutoCAD's samples when DRAFTCRAFT_DWG_SAMPLES names their folder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…text in DXF Compared with AutoCAD's DXF of the same drawings (ACadSharp's samples): - ACAD_TABLE (2010 and later): a cell's text height is the one its first content's format sets (override bit 0x80), else its own style's, else its row's, else its column's; otherwise it takes the table's. AutoCAD fills every format's height in from the style, so taking it whatever the flags gave 0.18 where AutoCAD's DXF has its rows' 0.1026 and 0.1425. AutoCAD's files set the style's property bits in its first flag word, acadrust (the writer DraftCraft uses for DWG) in the second: either counts. The two dwg_table_cell_height tests that failed with the direct reader pass. - DXF tables: a cell whose value is no string (a number, angle, date, point, percentage) shows its value block's formatted text (302), as AutoCAD writes it: it read empty. The DWG reader has the same rule. - SPLINE, 2013 and later: tangents of unit length are directions, as DraftCraft's saves store them (DraftCraft's own fit); others are AutoCAD's derivatives. The comparison test expects AutoCAD's curve for a spline made with acadrust's API and tangents (1, 1) and (1, -1). - WIPEOUT and IMAGE: the clip polygon stays as the DWG stores it (open); the drawing holds a boundary open or closed alike (Wipeout::vertices), and closing it changed DraftCraft's own wipeouts on a round trip. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
From AutoCAD's own 2018 file (ACadSharp's samples), compared with its DXF: - MTEXT: after the background fill (its scale, colour and transparency when it is filled), a text that is not annotative carries a copy of its frame of reference and its columns: type, count, width, gutter, auto height, flow, and the heights of dynamic columns of manual height. They read by the DXF reader's rules for the embedded object (group 101): AutoCAD stores a height negative where its DXF has 0, and dynamic auto-height columns store no count. Kept only when the record ends where they do. - ATTRIB and ATTDEF of type 2 and 4: the multiline text is an MTEXT embedded in the record, an entity's common properties then the MTEXT's fields, then the number of secondary attributes. The attribute keeps it as its multiline text and its plain reading as its value, as the DXF reader does; its block reference is no longer left out. The embedded text's references follow the attribute's own text style in the handle stream. - The test that pinned the refusal now checks DraftCraft's own 2018 multiline attributes read back as saved; AutoCAD's samples check columns and attributes when DRAFTCRAFT_DWG_SAMPLES is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
AutoCAD's DXF of ZIGZAG and BATTING (ACadSharp's samples, saved by AutoCAD in every version) has group 50 = 180 where its DWG of the same drawing has pi: AutoCAD writes and reads an embedded shape's or text's rotation in degrees, whatever the DXF Reference says. DraftCraft read and wrote radians, so AutoCAD's linetypes turned 180 radians and AutoCAD turned DraftCraft's by pi degrees; the DWG save, through acadrust reading the bridge DXF as degrees, shrank every rotation (the test of that was ignored as unexplained). - The DXF writer writes degrees and marks the linetype with DraftCraft extended data (LTYPE_DEGREES). - The DXF reader reads degrees, except in a file an earlier DraftCraft wrote: its DRAFTCRAFT application registered and its linetypes unmarked, whose rotations are radians. - complex_linetype_rotation_is_correct_in_native_objects runs again and passes; a reader test covers AutoCAD's, an earlier DraftCraft's and the new files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
MLEADERSTYLE objects (written from 2004 on) are read into the drawing's multileader styles, named by the ACAD_MLEADERSTYLE dictionary, by the DXF reader's rule: the arrow size, text height, landing gap, dogleg length, text style and whether new multileaders are annotative. The fields are read in the order AutoCAD's own files hold them (ACadSharp's samples): every version reads to the end of the record with the values of AutoCAD's DXF; 2010 adds a version first and the attachment directions last, 2013 a flag; the annotative flag comes before the changed flag. The drawing lost every multileader style but the default, and with it the annotative one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…tyles The objects of the named-object dictionary are read: dictionaries, XRECORDs, scales, dictionary variables, groups, wipeout and raster variables, plot-style names and table styles. DraftCraft's own records (constraints, layer states, plot styles, annotation, the current multileader style, the handle seed) go through the same rules as the DXF reader, which now shares them (apply_scales, apply_own_records, put_groups, scale_from). Objects under a dictionary DraftCraft does not model are kept as foreign objects with their DXF groups, as the DXF reader keeps them. Codec: XRECORD strings before AutoCAD 2007 have a 16-bit length and a code page byte (reader and writer); ObjectReader::non_graphic and DwgFile::class_of expose the decoded objects and classes. Table styles: the legacy layout (colours as true-colour records) and the 2010+ layout with named cell styles, read to DXF's groups. The unnamed handle AutoCAD 2013 added to the header is no variable. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
AutoCAD 2007 to 2009 files open: the file header, the page map and the section map are read from their Reed-Solomon codewords (the data bytes are taken; the parity is not checked), pages are decompressed with the 2007 scheme, and each section is reassembled from its pages. Every size read from the file is bounded before anything is allocated for it, and a damaged stream is an error, never a panic (tests in r2007.rs). AutoCAD's own 2007 files (MI-201 and the ACadSharp sample) read like the other versions; the direct-reader tests now run 2007 with the rest. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…e styles - A VPORT record holds the view's width, not its aspect ratio: AutoCAD's *Active viewport stores 2988.21 for a height of 1100.22 where its DXF has the ratio 2.716. The ratio is now the width over the height. - DWG text is stored as it is: AutoCAD's files hold a line feed as the character itself, where DXF writes `^J`. The DXF escapes (`^ `, `^I`, `^J`) are no longer decoded in DWG text, so a caret followed by a space stays. - A multiline attribute's embedded text has its own handles in the handle stream (a null owner, layer, linetype and material in AutoCAD's files), then its text style, which was read as the attribute's. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…n function Keeps the entity reader under the lint's complexity limit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
The objects pass keeps what the DXF reader keeps of a DXF file, by the same rule (dxf_raw::retained_objects): - an entity's, table record's, table's or block record's extension dictionary and the objects under it, unless every entry is one the drawing models (dimension associativity, draw order, annotation contexts), whose entries are stripped from a kept dictionary; - the reactors that are kept objects; - an entity's material (group 347); - other applications' extended data on table records and block records; - the roles of the handles kept data refers to (a layer, a table, a block record, the named object dictionary and its entries), so that saving points them at whatever has that role then. The entity pass hands over each entity's extension dictionary, reactors and material instead of counting them as unread. The pass is split into decode, model and keep. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…d note
- SPATIAL_FILTER is decoded to the DXF groups AutoCAD writes of it, and a
block reference's clip is taken from it by the DXF reader's rule
(dxf_clip::read).
- OLE2FRAME is kept as the DXF reader keeps it: an entity of a type the
drawing doesn't model, with the groups a DXF file has (the frame's corners
from the data's wrapper, the data as it is). The same path serves the other
types the drawing keeps without modelling.
- HELIX is read by the DXF reader's rule, from the same groups.
- What the reader leaves out is noted in the app's words for a file read in
part ("N of M object records couldn't be read and were left out (...);
saving over the original file would lose them"), which the CLI and the
status line already show.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…text - A file DraftCraft wrote names its next handle (DRAFTCRAFT_HANDSEED): the reader follows it, as the DXF reader does, instead of taking every handle of the file first. Opening and saving a DWG again no longer moves the seed, so the saved file is the same each time. - 3DSOLID, REGION and BODY whose description is text (up to AutoCAD 2010, as AutoCAD 2000 files and DraftCraft's own have it) are kept as the groups a DXF file has, extended data included. The binary description and the 2013-and-later data store are not read yet and stay in the read note. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
Keeps the type dispatch under the lint's complexity limit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
…and 13 The direct reader keeps what the old path lost, so the tests that recorded these as known losses run again: a layer's named plot style, a leader's vertex heights, an attribute's constant flag, a space after an MTEXT caret, and the current layer. docs/dwg.md: steps 12a, 12b and 13 as read, what a real file still leaves in the read note (12c), and the misreads found on AutoCAD's files with their fixes. 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
docs/dwg-handoff.md: the state of DWG reading and writing, how to build and test it, the four tests that fail and what each needs, what a file can still lose on opening, the known differences from AutoCAD's DXF, and what is left. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F67RspwBCoRVMtoi14joCg
DWG: open with the direct reader (acadrust disabled), and what testing it found. Work is incomplete. Handing off to SkryxDev
2 of 3 tasks
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.
Current state is that DraftCraft DWG can read all versions and years, but can't write, so acadrust cannot be disabled and the application still write DWG.
More work is needed. See dwg-handoff.md in PR for a full review.