ixmilia / dxf-rs

MIT License
99 stars 34 forks source link

UnexpectedCode Err on $ACADMAINTVER #27

Closed usagi closed 2 years ago

usagi commented 2 years ago

Err

let o = dxf::Drawing::load_file("a.dxf").unwrap(); // <- src/main.rs:5

Problem

This a.dxf contains $ACADMAINTVER. A part of it is shown below:

︙
HEADER
  9
$ACADVER
  1
AC1032
  9
$ACADMAINTVER
 90
       55
  9
$DWGCODEPAGE
  3
︙

Note that the library worked as expected when 4 lines were removed from $ACADMAINTVER.

usagi commented 2 years ago

Additional info:

And I was run with debugger, then I found the code in "target/debug/build/dxf-9a553b685b0574c6/out/generated/headers.rs" L1471:

            "$ACADMAINTVER" => { verify_code(&pair, 70)?; self.maintenance_version = pair.assert_i16()?; },

And, the specification indeed states that it is 70 => https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-A85E8E67-27CD-4C59-BE61-4DC9FADBE74A . I do not know if this library should allow 90 or if ODAFileConverter should output 70 even in DXF2018. 🤔

WCarrollSTO commented 2 years ago

I, too, am running into this.

Using AutoCad LT 2022, I am also getting $ACADMAINTVER set to 90, despite what the docs show.

That said, the docs say Maintenance version number (should be ignored). Should this, indeed, be ignored?

brettfo commented 2 years ago

While the docs report that $ACADMAINTVER should be ignored, I'd like to keep the field in case somebody needs to use it.

I've pushed commit 17265bf519dbfed4d281a12996735ac6380c0ad5 to main that will allow reading $ACADMAINTVER as a code 90, but internally it's still stored as i16 and only written as code 70.