michal-josef-spacek / CAD-Format-DWG-AC1009

Read AutoCAD r11 DWG file.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

AUX HEADER #3

Closed leshasoft closed 1 year ago

leshasoft commented 1 year ago

I hacked this structure


SIZE        DESCRIPTION
2 bytes     Value 16
2 bytes     Size of aux header
4 bytes     Entity start address
4 bytes     Block def start address
4 bytes     Extra ent start address
1 byte      Value 1
1 byte      Value 0
8 bytes     HANDSEED variable
2 bytes     Number of records
---------------------------------
    N records, where:
2 bytes      Section id
2 bytes      Size section records
2 bytes      Number records in section
4 bytes      Address section
----------------------------------
4 bytes      Address aux begin sentinel
2 bytes      CRC
16 bytes     sentinel
michal-josef-spacek commented 1 year ago

@leshasoft Interesting.

I have:

  aux_header:
    seq:
      - id: aux_header_sentinel_begin
        contents: [0x29, 0x8D, 0xD1, 0x49, 0xA9, 0x73, 0x1F, 0xEA, 0x99, 0xDE, 0x32, 0xF9, 0x4D, 0x0A, 0xE0, 0x19]
      - id: u2
        type: s2
      - id: u3
        type: s2
      - id: entities_start
        type: s4
      - id: entities_end
        type: s4
      - id: blocks_start
        type: s4
      - id: blocks_end
        type: s4
      - id: handling
        type: u2
      - id: handseed
        size: 8
      - id: num_aux_tables
        type: u2
      - id: aux_tables
        type: table_aux
        repeat: expr
        repeat-expr: num_aux_tables
      - id: u1_address
        type: s4
      - id: crc16
        size: 2
      - id: aux_header_sentinel_end
        contents: [0xD6, 0x72, 0x2E, 0xB6, 0x56, 0x8C, 0xE0, 0x15, 0x66, 0x21, 0xCD, 0x06, 0xB2, 0xF5, 0x1F, 0xE6]

You are right, that could be size and different addresses.. Thanks.

michal-josef-spacek commented 1 year ago

I added size (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/784c137c586bb4c1095386dfdf4ea24d813c069d)

michal-josef-spacek commented 1 year ago

This 2 bytes Value 16 is sentinel size maybe :-)

leshasoft commented 1 year ago

It seems yes :)

michal-josef-spacek commented 1 year ago

or number of items in aux header

michal-josef-spacek commented 1 year ago

I fixed addresses (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/9d1c59f8bb09f4e5d2fd84728d972fa8d6aea4de)

michal-josef-spacek commented 1 year ago

Result for me is:

SIZE        DESCRIPTION
16 bytes    sentinel begin
2 bytes     Value 16
2 bytes     Size of aux header
4 bytes     Entity start address
4 bytes     Entity end address
4 bytes     Block def start address
4 bytes     Extra ent start address
2 bytes     HANDLING variable
8 bytes     HANDSEED variable
2 bytes     Number of records
---------------------------------
    N records, where:
2 bytes     Section id
2 bytes     Size section records
2 bytes     Number records in section
4 bytes     Address section
----------------------------------
4 bytes     Address aux begin sentinel
2 bytes     CRC
16 bytes    sentinel end
leshasoft commented 1 year ago

or number of items in aux header

It's hard to understand here. Many files number of sections is equals, then it was not possible to determine. P.S: I also had the idea that the byte at the address 0xc is a sign of the presence aux header.

michal-josef-spacek commented 1 year ago

or number of items in aux header

It's hard to understand here.

That's true.

But. There is a number of header variables (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/blob/main/dwg_ac1009.ksy#L227) which is similar to this concept . I can say that this variable is right.

Many files number of sections is equals, then it was not possible to determine.

Yes, I want to check.

P.S: I also had the idea that the byte at the address 0xc is a sign of the presence aux header.

No. I have AC1002 to AC1009 documents with this value = 1. Aux header have AC1009 only. Interesting idea.

leshasoft commented 1 year ago

:( Plise send me some files, I'll take a look. Maybe I'll find how they differ from the rest.

michal-josef-spacek commented 1 year ago

@leshasoft 0x1c 1 byte:

leshasoft commented 1 year ago

The document ODA says about this byte: "We have occasionally seen other values here but their meaning (and importance) is unclear." :(

Can I ask you? You don't know what the variable at the address is 0x547? Contains 3 double value 0.0 or unknown 24 bytes.

        0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F                                                                   
000500 FD 00 01 00 00 00 73 12-01 00 00 00 06 00 00 00   ......s.........                                               
000510 FF FF 25 00 01 00 00 00-90 13 01 00 01 00 05 00   ..%.............                                               
000520 01 00 44 01 00 00 00 00-D5 13 01 00 FF FF 00 00   ..D.............                                               
000530 00 00 00 00 00 00 00 03-00 46 00 00 00 00 00 00   .........F......                                               
000540 00 1C 00 7E FD 57 42 DC-F0 6A CA C8 58 31 3D E2   ...~.WB..j..X1=.                                               
000550 70 A1 3F F8 83 AD 42 2B-71 63 33 52 39 6B 45 6D   p.?...B+qc3R9kEm                                               
000560 65 74 65 72 00 00 00 00-00 00 00 00 00 00 00 00   eter............                                               
000570 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 A4   ................
michal-josef-spacek commented 1 year ago

Can I ask you? You don't know what the variable at the address is 0x547? Contains 3 double value 0.0 or unknown 24 bytes.

https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/blob/main/dwg_ac1009.ksy#L801

...
      - id: unit1_ratio
        type: f8
      - id: unit2_ratio
        type: f8
      - id: unit3_ratio
        type: f8
      - id: unit4_ratio
        type: f8
      - id: unit1_name
        size: 32
        type: str
        encoding: ASCII
        terminator: 0x00
      - id: unit2_name
        size: 32
        type: str
        encoding: ASCII
        terminator: 0x00
      - id: unit3_name
        size: 32
        type: str
        encoding: ASCII
        terminator: 0x00
      - id: unit4_name
        size: 32
        type: str
        encoding: ASCII
        terminator: 0x00
...
leshasoft commented 1 year ago

+qc3R9kE It doesn't look like a floating value.

michal-josef-spacek commented 1 year ago

+qc3R9kE It doesn't look like a floating value.

Real data:

unit1_ratio: 412148564080.000000 [RD 0]
unit2_ratio: 0.000000 [RD 0]
unit3_ratio: 16226321420472.441406 [RD 0]
unit4_ratio: 263293506840482798429536256.000000 [RD 0]
unit1_name: "meter" [TFv 32 1]
6D65746572000000000000000000000000000000000000000000000000000000
unit2_name: "inch" [TFv 32 1]
696E636800000000000000000000000000000000000000000000000000000000
unit3_name: "inch" [TFv 32 1]
696E636800000000000000000000000000000000000000000000000000000000
unit4_name: "sq inch" [TFv 32 1]
737120696E636800000000000000000000000000000000000000000000000000

I don't understand how is this created in AutoCAD and what precisely means.

leshasoft commented 1 year ago

Thank you

michal-josef-spacek commented 1 year ago

Many files number of sections is equals, then it was not possible to determine.

Yes, I want to check.

All files, which I have have numbers 16 (unknown) and 138 (aux header length)

michal-josef-spacek commented 1 year ago

I changed unknown to:

- id: num_aux_header_variables
        type: s2

I am pretty sure, that's true. 16 variables: