Skip to content

[Bug] A drawing opened and saved by CADCraft crashes AutoCAD 2021 on open (DWG and DXF), from a Rhino-exported DWG #3303

Open

Description

@kuseidos

A drawing that came from Rhino opened in CADCraft without trouble. After editing it there and saving, neither the DWG nor the DXF opens in AutoCAD 2021: AutoCAD crashes, and the work had to be restarted from scratch. That is the part worth being loud about — a file that silently cannot go back is worse than one that refuses to save.

Steps

  1. A .dwg exported from Rhino. It opens in CADCraft normally.
  2. Work on it in CADCraft, save — as DWG, and once as DXF.
  3. Open either saved file in AutoCAD 2021: impossible. AutoCAD crashes on the file.

What I know and what I do not

  • CADCraft version: not recorded before the file was lost — please tell me which to try if it matters (0.20.1 is current as I write this).
  • Which save was used for each attempt (Save, Save As, Export) I can also re-check, but the result was the same for both formats.
  • The input came from Rhino, which writes DWG through its own exporter, so the source is not an AutoCAD-native file even though it opened fine on the way in.
  • AutoCAD 2021 is the reader, and it is a crash rather than a message, so there is nothing for me to paste from it.

What would let anyone here reproduce it

I do not want to hand over a private production drawing, but I can produce a minimal version of it — the same Rhino → CADCraft → save path, with the drawing reduced until it still crashes AutoCAD — if that helps. Say which of these you would rather have:

  1. the reduced file and the exact CADCraft version,
  2. the original file privately, or
  3. a list of the entity types you suspect, so I can build a file with only those.

Why it may be one of the known families

Reading the tracker, this looks like the same shape as the open file-compat reports rather than a new mechanism:

A saved file that a different program crashes on, with no signal from CADCraft, is the common thread. #2334 is the closest in symptom (it names a second reader refusing the output), so if a maintainer thinks this is a duplicate, I will fold it there — but the reader here is AutoCAD 2021 on a DWG, and the report does not cover that.

What a better gate would look like

cadcraft-cli roundtrip (#2685) already opens, saves and reopens — which catches what a second CADCraft cannot read, not what another program chokes on. The gap is the same one #2643 states: a conversion that returns 0 while the output is unreadable. Two things would have caught this class before a person lost a day:

  • an external readability check in the corpus run (open the saved file with a validator, or at least with a second independent reader), so "CADCraft can reopen it" stops standing in for "it is a valid file", and
  • a warning at save time when the writer drops records or leaves entities it does not model — the writer already counts them (the DWG worker returns per-type counts since DWG reader and writer run in a child process (E7) #2673), so the count could reach the person instead of only the log.

I am happy to help test either, on Linux and Windows, with files I can share.

Activity

  1. ticket-craft commented on Nov 20, 2026

    @ticket-craft

    Thanks for the report! To look into this, we need the app version and a sample file that shows the problem. Please add them in a comment here, or open a new ticket with the details.

    Possibly related: #2334 and #2920.

  2. kuseidos commented on Nov 20, 2026

    @kuseidos
    Author

    The two programs say different things, and the difference is the useful part.

    AutoCAD 2021 on the DWG — a crash, no diagnostic:

    AutoCAD Error Aborting
    FATAL ERROR: Unhandled Access Violation Reading 0x5d61100c
    Exception at 6D488B6Bh
    

    AutoCAD 2021 on the DXF — refused, drawing discarded, and it names the record:

    The following error was encountered while reading
    in HATCH starting at line 163292:
    Error: expected group code 98
    Invalid or incomplete DXF input -- drawing discarded.
    

    Version: 0.20.1 (About dialog), which is the release multimann confirmed the DXF error on in #2904.

    The DXF half is #2904, and it is fixed there

    Same message, same version. Since #2665 the writer puts groups 52 (pattern angle), 41 (pattern scale) and 77 (double flag) on solid and gradient fills too, and AutoCAD's reader refuses any of the three between 76 and 98 — which is exactly what expected group code 98 means: it never gets to the seed-point count. #2904 writes them for pattern fills only again and measured opened files in AutoCAD 2024 and 2026. So this DXF is a duplicate of that one and I will not open a second front for it; the fix is written and waiting to merge.

    The DWG half may be the same defect, and that is worth knowing before triaging it separately

    DWG saves do not start from the drawing model: write_dwg in crates/io/src/lib.rs builds dxf_write::dwg_bridge(d, version) and hands that DXF text to craft_dwg::encode_kept_noted, i.e. acadrust parses the same bytes and encodes the DWG. The malformed solid/gradient hatch record therefore travels into the DWG as well. A DWG reader handed a hatch record in the wrong shape can fault where the DXF reader would have refused it politely, which is the shape of the difference above.

    Two things follow:

    1. If DXF: a solid or gradient hatch no longer makes AutoCAD refuse the file #2904 cures the DWG too, this issue closes with it, and the only thing left is a note that AutoCAD's DWG reader crashes rather than refusing — worth a bug report to Autodesk's parser resilience, not to us.
    2. If it does not, the DWG half belongs to craft-dwg rather than to this repo, and it needs the same kind of measured table DXF: a solid or gradient hatch no longer makes AutoCAD refuse the file #2904 has: a drawing AutoCAD wrote itself with a solid hatch, converted here to DWG, opened there.

    For the reporter's own file, meanwhile

    The trigger is a solid fill or a gradient; patterned hatches (ANSI31 and the like) are not affected, they open in the #2904 measurements. So a drawing whose solid fills are exploded to lines before saving should open. I can also reduce the file to the smallest version that still fails, on both formats, if a maintainer wants a fixture they can keep — I have not attached the drawing because it is private production work.

  3. kuseidos commented on Nov 20, 2026

    @kuseidos
    Author

    A measurement that narrows the DWG half, and it goes against my own guess, so it belongs here before anyone spends time on it.

    The DWG does not inherit the hatch defect. DWG saves are built from the same tags (dxf_write::dwg_bridge → craft_dwg::encode_kept_noted), so I expected the malformed solid-hatch record to travel into the DWG and trip AutoCAD's reader there. It does not: the bridge decodes the DXF into the DWG model and writes the groups back from its own fields, and a solid fill comes out clean even on main.

    How it was measured — a drawing with one SOLID hatch and one ANSI31 hatch, cadcraft_io::write(&d, "x.dwg"), then craft_dwg::dwg_to_dxf and the HATCH records read back:

    solid fill   : 70=1, 76 followed by 98, no 52, no 41, no 77
    pattern fill : 70=0, 76 … 78 …, 52, 41 and 77 present
    

    So main's DWG is already what AutoCAD wants for a hatch, and a test asserting it passes with the bug still in the DXF writer — which is why I did not keep the test: a check that cannot fail is worse than none. It does say what the DWG path does, so it may be worth a /// note or a case in crates/io/tests/it/hatch_dwg_bridge_groups.rs if a maintainer wants the behaviour pinned for another reason.

    What that leaves. The access violation on this reporter's DWG is a different defect from #2904, and the DXF's expected group code 98 is the first thing AutoCAD's reader refused, not necessarily the only thing wrong with the drawing. The input was a Rhino export, which is the shape #2334 describes (REGION/3DSOLID/ACIS data read from a DXF making every saved DXF/DWG unreadable elsewhere, priority: critical) — and AutoCAD meets the hatch problem first in the DXF while the DWG has no hatch problem at all, which fits a second cause behind the first.

    Next step from my side: an inventory of the entity types in the saved file, which does not need AutoCAD and does not need the drawing to be published — if cadcraft-cli info on the saved DWG prints counts per type, the report can name what the file holds without the file leaving the reporter. I will post that here when I have it.

  4. kuseidos commented on Nov 29, 2026

    @kuseidos
    Author

    Checked the release rather than the notes alone, since this report was filed against 0.20.1:

    • v0.21.0 (28 Nov) carries DXF: a solid or gradient hatch no longer makes AutoCAD refuse the file #2904. Its release notes list it — "DXF: a solid or gradient hatch no longer makes AutoCAD refuse the file by @2ez4gcx" — and the tag's own source has it: write_hatch_entity writes 52, 41 and 77 inside if !h.solid, so a solid or gradient fill goes from its pattern type (76) straight to its seed points (98).
    • So the DXF half of this report is closed for anyone on 0.21.0, and the reporter's 0.20.1 is the version that still writes them. That is what "expected group code 98" was.

    The DWG half is not covered by that fix and stays open here. The measurement above shows the DWG never carried those groups — the bridge rebuilds the hatch from its own fields — so the access violation comes from something else in the saved file. My own guess is the #2334 family: the input was a Rhino export, Rhino writes ACIS data (REGION/3DSOLID), and a drawing that carries it is exactly what #2334 describes as unreadable elsewhere with exit code 0 from CADCraft. That is a guess and I am labelling it as one; the file decides.

    What I am still waiting on is the saved DWG from the reporter, so a maintainer can look at what the file actually holds instead of at what we think it holds. When it arrives I will post the entity inventory here — counts per type, no private geometry — and a reduced file if the reporter agrees to share one.

  5. kuseidos commented on Nov 30, 2026

    @kuseidos
    Author

    The reporter no longer has the saved DWG — the project was rebuilt from scratch after the file would not open — so this half cannot be reproduced from our side, and I would rather say that than keep a report open on a promise of a file.

    What remains true and useful in this issue:

    If someone else has a DWG that CADCraft saved from a Rhino export and faults in AutoCAD, that file is worth more than anything we can add here, and this issue is the right place to hang it. Closing or keeping it is your call — I do not have more to add without an input file.

  6. 2ez4gcx commented on Dec 3, 2026

    @2ez4gcx
    Contributor

    Following up on kuseidos' summary of 30 November. This issue now holds two things:

    Since there's nothing left to act on without a file, I'd suggest closing this in favour of #2334. If anyone has a DWG that CADCraft 0.21.0 or later saved and that AutoCAD can't open, please attach it, or open a new issue and link it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions