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

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

Block entities defintion #2

Closed michal-josef-spacek closed 1 year ago

michal-josef-spacek commented 1 year ago

From @leshasoft in https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/issues/1#issuecomment-1413485702:

In header by offset 0x24 4 bytes of address second entities table,
by offset 0x28 2 bytes size of table.
michal-josef-spacek commented 1 year ago

@leshasoft My actual understanding Example: INSERT1.scr.gz INSERT1.DXF.gz INSERT1.DWG.gz

Visualization by ksv tool INSERT1

...
    [.] entities_start = 1743
    [.] entities_end = 1869
    [.] blocks_start = 3239
    [.] blocks_size_raw = 1073741926    # V
    [.] blocks_end = 3373                          
    [.] unknown4b = 00 00
    [.] unknown4c = 00 80
...
    [-] blocks_size_unknown = 64        # last byte in blocks_size_raw (0x40)
    [-] blocks_size = 102               # first three bytes in blocks_size_raw
...
leshasoft commented 1 year ago

VERSION ID: AC1009 Number heder Variables: 205 Entity list start: 0X6CF Entity list end: 0X74D Block def start: 0XCA7 Extra ent start: 0XD2D Extra ent size: 0 Block hdr start:0X76D Size:0X2D Number:1 Layer list start:0X7BA Size:0X29 Number:1 Shape list start:0X803 Size:0XC6 Number:1 Ltype list start:0X8E9 Size:0XBF Number:1 View list start:0X9C8 Size:0X99 Number:0 UCS list start:0X9E8 Size:0X6D Number:0 Vport list start:0XA08 Size:0XFD Number:2 Regapp list start:0XC22 Size:0X25 Number:1 Dymstyle list start:0XC67 Size:0X144 Number:0 Vportent list start:0XC87 Size:0X2B Number:0

leshasoft commented 1 year ago

block def size 2 bytes of offset 0x20

michal-josef-spacek commented 1 year ago

Hm, interesting. The extra ent. table is new for me. And seems that you are right. I will look to it.

michal-josef-spacek commented 1 year ago

All AC1009 which I was looked has 186 bytes in this address (Extra ent start). I don't know what this mean. libredwg has some auxheader section, so I will add TODO for it.

michal-josef-spacek commented 1 year ago

first version of aux header: https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/27a699a7e3b641413e1b58ea1ece00393f723390

michal-josef-spacek commented 1 year ago

Hm, this is another independent task with this aux header. But i understand what happened

leshasoft commented 1 year ago

ROZA.DWG.gz

You are right, this is another independent task. I have not figured out this structure yet.

(16 bytes sentinel + 16 bytes sentinel+136 bytes + 2 bytes crc + 16 bytes sentinel)

06E0EF 2A 06 2C 44 F5 56 96 59-32 E3 78 38 11 7F B4 E8   *.,D.V.Y2.x8...
06E0FF 29 8D D1 49 A9 73 1F EA-99 DE 32 F9 4D 0A E0 19   )..I.s....2.M...
06E10F 10 00 8A 00 CF 06 00 00-FF B0 04 00 66 C1 04 00   ............f...
06E11F EF E0 06 00 01 00 00 00-00 00 00 07 25 68 0A 00   ............%h..
06E12F 01 00 2D 00 31 00 1F B1-04 00 02 00 29 00 08 00   ..-.1.......)...
06E13F DC B9 04 00 03 00 C6 00-01 00 44 BB 04 00 05 00   ..........D.....
06E14F BF 00 03 00 2A BC 04 00-06 00 99 00 00 00 87 BE   ....*...........
06E15F 04 00 07 00 6D 00 00 00-A7 BE 04 00 08 00 FD 00   ....m...........
06E16F 02 00 C7 BE 04 00 09 00-25 00 01 00 E1 C0 04 00   ........%.......
06E17F 0A 00 44 01 00 00 26 C1-04 00 0B 00 2B 00 00 00   ..D...&.....+...
06E18F 46 C1 04 00 FF E0 06 00-08 00 D6 72 2E B6 56 8C   F..........r..V.
06E19F E0 15 66 21 CD 06 B2 F5-1F E6                     ..f!......      

Attached for example DWG R10 If I find a file DWG R11 in our archives that does not contain a commercial secret, I will attach it as an example.

leshasoft commented 1 year ago

OTKR.DWG.gz DWG R11 file where Extra ent table not empty.

michal-josef-spacek commented 1 year ago

@leshasoft Thank you, I have information to improve and fix code. In progress.

michal-josef-spacek commented 1 year ago

First step: Fixed entity sections (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/7687798a165475062dfd7168e72946c1027e124c)

leshasoft commented 1 year ago

sentinels.txt.gz

List of sentinels. maybe come in handy.

michal-josef-spacek commented 1 year ago

sentinels.txt.gz

List of sentinels. maybe come in handy.

Thank you. I think that first DWG_SENTINEL_R11_HEADER_END is begin of entities section.

Everything is clean for me, I need to implement.

leshasoft commented 1 year ago

Yes you are right this is begin of entities section.

michal-josef-spacek commented 1 year ago

Second step: Identify extra entity section (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/ebc33fc01269a8436d95704d7fc6ed3ccb082d8b)

michal-josef-spacek commented 1 year ago

sentinels.txt.gz

btw: Do you creating patch to libredwg? Seems as libredwg sentinel code :-) We need to patch it, i have some code prepared.

michal-josef-spacek commented 1 year ago

Third step: Identify sentinels (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/c4bc630d10ef34a01f332b223ebfb6a6d2ef7c0e)

leshasoft commented 1 year ago

btw: Do you creating patch to libredwg?

No, this is code from my program, you can use it for LibreDWG.

michal-josef-spacek commented 1 year ago

btw: Do you creating patch to libredwg?

No, this is code from my program, you can use it for LibreDWG.

ok, thanks.

michal-josef-spacek commented 1 year ago

Fourth step: Simplify main sequence (https://github.com/michal-josef-spacek/CAD-Format-DWG-AC1009/commit/6f5ba28ce1e80b731d9ae3bc2cb5eff5b87ab89d)

michal-josef-spacek commented 1 year ago

@leshasoft I am closing this issue, thank you very much. Finished: