Roadmap 0.9, From GitHub (to review)

GH.5 DWG reader: class list fails when a class's maintenance version is 256 or more (read as BITSHORT, spec has BITLONG)

  • Feature
  • Built · Live
  • CadCraft

## Summary

`readClassesSection` in `app/dwg/read.js` (line 229) reads each R2004+ class record's DWG version and maintenance version as BITSHORT. The Open Design Specification for .dwg files v5.4.1, chapter 10, gives both as BITLONG. The two encodings agree for values 0 to 255 and part from 256 up: BITSHORT code 00 is followed by 16 bits and BITLONG code 00 by 32, and BITSHORT code 11 means 256 where BITLONG has no code 11. So a class whose maintenance version is 256 or more shifts every later field by 16 bits, and the read stops with `Classes could not be read: bad BITLONG code 11`.

## Where we saw it

Three real R2018 (AC1032) drawings from a third party (we cannot share the files). Their class records carry DWG version 33 with maintenance version 329 for MLEADERSTYLE, ACDBDETAILVIEWSTYLE and SUN. The classes before the first of those (ACDBDICTIONARYWDFLT, MATERIAL, VISUALSTYLE, SCALE, TABLESTYLE) read fine, so the read fails on the class right after MLEADERSTYLE. A fourth R2018 drawing whose classes are all below 256 reads correctly.

## Effect

- `model.classes` comes back empty, with the note `Classes could not be read: bad BITLONG code 11`.
- Every class-based object then reads as unknown (`CLASS_5xx` in `report.unknown`). In our files that included two IMAGE entities inside a title block definition, which dropped out of the drawing.
- `writeDwg(readDwg(bytes), { version: 'AC1032' })` leaves those objects out: "Not copied (cc-dwg cannot write them in this version, or they depend on them): 3 CLASS_501, 24 CLASS_502, 17 CLASS_503, 1 CLASS_504, 1 CLASS_505, 1 CLASS_506, 1 CLASS_507, 1 CLASS_508, 2 CLASS_511, 2 CLASS_512, 1 CLASS_513, 5 CLASS_509."

Model space, layer…

Opened on GitHub by a Discord member: https://github.com/getcadcraft/cadcraft/issues/5

Sweep 2026-11-05: accepted into 0.9 (planned).

cad-fix-09 2026-11-05 (done): see docs/0.9-sessions/cad-fix-09.md.

From: a Discord member

cadcraft#5 open

Add a comment

Community comments

No comments yet

Add detail as we go: how you would use it, files or steps that show the problem, what other programs do. The team reads every comment.

Sign in or create a free account to add a comment.