LibreDWG / libredwg

Official mirror of libredwg. With CI hooks and nightly releases. PR's ok
https://savannah.gnu.org/projects/libredwg/
GNU General Public License v3.0
947 stars 230 forks source link

Broken Text Style write on win64 only #346

Closed Dev7741 closed 3 months ago

Dev7741 commented 3 years ago

With font_file: arial.ttf (EED name "Arial", flag 34).

michal-josef-spacek commented 1 year ago

@timoria21 When I dwgrewrite your original file, there are still some issues in AutoCAD 2000. And the difference between DWG files are same as diff in the previous comment. I believe that we need to fix these issues first.

timoria21 commented 1 year ago

Thanks for checking this for me, again let me know if I can help/test in some way.

So, nobody has an idea of what triggers the RecoveryMode in AutoCAD.

I think it would be a great value for the LibreDWG project to write DWG files correctly.

michal-josef-spacek commented 1 year ago

After fixing of strings_area issue still persists.

michal-josef-spacek commented 1 year ago

After the provisional fix of https://github.com/LibreDWG/libredwg/issues/785 I have an equal JSON result. Interesting. Issue still persists.

So I am going to compare binary files.

michal-josef-spacek commented 1 year ago

After the provisional fix of #788 issue still persists.

michal-josef-spacek commented 1 year ago

@timoria21 I believe that the main issue of the DWG file which needs to be recovered is with a bad second header in conversion from JSON to DWG. After fixing https://github.com/LibreDWG/libredwg/issues/792 we need to check.

rurban commented 1 year ago

the remaining errors are in the CI under oda see eg. https://github.com/LibreDWG/libredwg/actions/runs/5870138178/job/15916583698

example_2018.dwg Object of class AcDbLayerTableRecord can't be cast to AcDbEntity. example_r14.dwg CRC does not match

earlier only some unknown recovery errors.

michal-josef-spacek commented 1 year ago

FYI: I had a situation when the output of DWG->JSON->DWG was without recovery mode but without 2nd header. I believe, that 2nd header is the important thing in the DWG structure.

michal-josef-spacek commented 1 year ago

After the previous fix, the issue is still here. New issue which I found is described in https://github.com/LibreDWG/libredwg/issues/803

michal-josef-spacek commented 1 year ago

hm, after fixing of previous, the issue is still here.

michal-josef-spacek commented 1 year ago

the remaining errors are in the CI under oda see eg. https://github.com/LibreDWG/libredwg/actions/runs/5870138178/job/15916583698

example_2018.dwg Object of class AcDbLayerTableRecord can't be cast to AcDbEntity. example_r14.dwg CRC does not match

earlier only some unknown recovery errors.

But this is roundtripping over the DXF file. Conversion to and from DXF is more problematic than JSON now.

michal-josef-spacek commented 1 year ago

I am testing roundtripping over the JSON and I have a simple line in AC1015, which is not working (need to be recovered). The main difference is in texts and then in sizes because of different texts. e.g. header

unit1_name: "m" [TV 0]

vs

TV-ZERO 2
unit1_name: "m" [TV 0]

I have a blank file, which has the same issues, but it's working after conversion without recovery. I don't see the root cause.

The same issue with recovery is on R14 file with one line.

michal-josef-spacek commented 1 year ago

The same issue is in the AC1012 file. Testing is blocked by https://github.com/LibreDWG/libredwg/issues/805 issue now.

rurban commented 1 year ago

Circle_Original.dwg can now properly json roundtrip without any teigha error anymore

michal-josef-spacek commented 1 year ago

JSON roundtrip by test-dwg-libredwg-json Circle_Original.dwg

33091,33092c33091,33092
<     "size": 117,
<     "address": 163713,
---
>     "size": 108,
>     "address": 164204,
33120,33121c33120,33121
<         "address": 163035,
<         "size": 678
---
>         "address": 163037,
>         "size": 1167
33125,33126c33125,33126
<         "address": 0,
<         "size": 0
---
>         "address": 164204,
>         "size": 117
33227c33227
<     "crc": 57194
---
>     "crc": 41100

There are only second header changes

The issue with recovery mode is present still.

There is something very wrong. e.g. The output of dwgadd for many AutoCAD versions is not usable by recovery issue. In AC1012-AC1015 maybe because write support of Thumbnail.

timoria21 commented 1 year ago

I had a situation when the output of DWG->JSON->DWG was without recovery mode but without 2nd header. I believe, that 2nd header is the important thing in the DWG structure.

Is this something we can remove, to get rid of the "recovery mode"?

rurban commented 1 year ago

I had a situation when the output of DWG->JSON->DWG was without recovery mode but without 2nd header. I believe, that 2nd header is the important thing in the DWG structure.

Is this something we can remove, to get rid of the "recovery mode"?

No, that's already fixed. Now we are getting closer. The remaining problems are some downconverting EED's mostly. The list of roundtrip errors is getting shorter every day

timoria21 commented 1 year ago

Wow, thanks! I look forward for this fix.

michal-josef-spacek commented 1 year ago

The list of roundtrip errors is getting shorter every day

@rurban Do you have some roundtrip errors? How to reproduce?

rurban commented 1 year ago

json-check all test dwgs

timoria21 commented 1 year ago

Does it mean we are still far from a solution?

Thanks.

michal-josef-spacek commented 1 year ago

@timoria21 The main question is what is the real issue? Still.

We concentrated on conversion between DWG and JSON (and back). We improved this much. From my point of view, it's fine.

When I tested the library, we could not create valid DWG files for some DWG versions (preR13 and AutoCAD 2000). I mean DWG files, which real AutoCAD could open. This is probably something simple (I believe that some default header variables or something like this) if you know what it is :-)

michal-josef-spacek commented 1 year ago

@timoria21 And the question to 0.13 milestone is for @rurban. I believe, that we need a new version, which is some step in development.

timoria21 commented 1 year ago

@michal-josef-spacek What DWG file version were you able to generate that the real AutoCAD can open without "Recovery Mode"?

Thanks.

michal-josef-spacek commented 1 year ago

I tested the actual version and via dwgadd I can create DWG files, which I cannot open in R14 and R2000. Error is Drawing file was created by an incompatible version. (R2000)

timoria21 commented 1 year ago

Does it mean that DWGs created by LibreDWG with version > R2000 open without "Recovery Mode" in the real AutoCAD?

michal-josef-spacek commented 1 year ago

Does it mean that DWGs created by LibreDWG with version > R2000 open without "Recovery Mode" in the real AutoCAD?

I am testing DWGs to the R2000 version. There are issues.

Versions after R2000 I don't know.

gentilinigm commented 12 months ago

For me, R2000 is actually the only version without the "Recovery Mode" issue. I tested it with a very simple file tho, containing only a line entity.

Here the test files, for reference.

michal-josef-spacek commented 12 months ago

For me, R2000 is actually the only version without the "Recovery Mode" issue. I tested it with a very simple file tho, containing only a line entity.

Hm, interesting set. :-)

Could you describe the process of creation of these files? As I understand:

Is it true?

gentilinigm commented 12 months ago

Yes, your understanding is correct.

More specifically:

michal-josef-spacek commented 12 months ago
  • All those files were created using AutoCAD2007, but saved in different versions.

Ah, ok, this is important.

my test: In AutoCAD R14 I could open line14.dwg, but could not open out14.dwg In AutoCAD R2000 I could open line14.dwg and line00.dwg, but could not open out14.dwg and out00.dwg Both because of incorrect or corrupted information. This is what I am writing above, generation of DWG files isn't ok now.

In the case of out07.dwg and out14.dwg, it's funny, because DWG files have AC1015 MAGIC (R2000 DWG file), but AutoCAD r2000 could not open because incompatible version. I don't understand what this means.

I am looking into this issue from lower versions step by step.

gentilinigm commented 11 months ago

I tried to add a custom layer to the file line00.dwg and apparently it was enough to break it:

AutoCAD
Warning: 2 errors were found during open. We recommend that you cancel this open and run RECOVER on the drawing. Would you like to cancel this open?
C:\Documents and Settings\Administrator\Desktop\out.dwg
Unable to open this drawing.
It contains incorrect or corrupted information.
The RECOVER command may be able to restore undamaged material from this drawing.

For reference

gentilinigm commented 11 months ago

I wanted to find how much impact do tables have. Thus, I tried the usual procedure (read - write - open) with a more complex file, removing different tables one by one (custom layers, custom line types, ...).

You can find everything at: app8 test 18-10-2023.zip

Unfortunately, recovery mode is always present, along with an error in the "_no l_no lt" and "_no l_no lt_no ds" files.

timoria21 commented 11 months ago

Come on guys, we are very close to resolving the recovery mode issue!

michal-josef-spacek commented 11 months ago

@gentilinigm I believe, that issue is related to basic structures (header vs auxheader/sec header).

This mean, in every write to DWG file, there is the issue.

rurban commented 11 months ago

In r2000 it is already fixed. There was a wrong CRC. From r2004 on there still minor problems somewhere. Mtext ATTRIBS eg.

michal-josef-spacek commented 11 months ago

@rurban I don't think that's true. I tested dwgadd with line and open in R14 and R2000 and there is an issue still.

rurban commented 11 months ago

I've only tested json-check for all r2000 files, and there's not a single oda error anymore

timoria21 commented 11 months ago

Thanks for the update @rurban. Where does this leave us? Is r2000 write now "Recovery Mode" free?

Can I start testing it?

michal-josef-spacek commented 11 months ago

@timoria21 As I understand, the situation is: There is a better situation in conversion from and to JSON. This is "mostly finished".

But the issue with "Recovery Mode" still persists. This means, that a problem is in another place. I don't know what is happening. I believe that it is related to the main information in the headers. There is a backup of the main header information. I believe that is the difference of main values between headers or something like that (CRC or whatever).

I am working on two tasks:

It is understandable?

rurban commented 11 months ago

There is also the open issue to keep section order. Mainly thumbnails

Michal Josef Špaček @.***> schrieb am Fr., 27. Okt. 2023, 14:05:

@timoria21 https://github.com/timoria21 As I understand, the situation is: There is a better situation in conversion from and to JSON. This is "mostly finished".

But the issue with "Recovery Mode" still persists. This means, that a problem is in another place. I don't know what is happening. I believe that it is related to the main information in the headers. There is a backup of the main header information. I believe that is the difference of main values between headers or something like that (CRC or whatever).

I am working on two tasks:

  • I am looking at the Second header structure, which is bad, I believe. The intent is a better possibility to check header and second header values.
  • I am working on header defaults for different versions of real AutoCADs. The intent is a better DWG file generated from libreDWG to compare with real DWG files.

It is understandable?

— Reply to this email directly, view it on GitHub https://github.com/LibreDWG/libredwg/issues/346#issuecomment-1782801589, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAKGUM3Z5DISUHWFPQYYLDYBOPR3AVCNFSM46BEVDQKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZYGI4DAMJVHA4Q . You are receiving this because you were mentioned.Message ID: @.***>

michal-josef-spacek commented 11 months ago

There is also the open issue to keep section order. Mainly thumbnails

Another problem could be with thumbnails. The ideal situation is filling in with a white thumbnail image in case of writing the DWG file by LibreDWG. We cannot rasterize the DWG file now to a thumbnail.

michal-josef-spacek commented 10 months ago

After fixing the decoding/encoding of the second header, the issue is still here :-D

michal-josef-spacek commented 10 months ago

From my point of view, PR https://github.com/LibreDWG/libredwg/pull/865 fixes this issue. I will wait for the merge and I will test more.

dwgadd output does not work still, probably for different format of handles in 2ndheader.

michal-josef-spacek commented 10 months ago

New version of #865 . That was definitely a problem with the encoding of the second header (new section found before). Still issues in encoding.

michal-josef-spacek commented 10 months ago

Guys in this ticket :-), could you help me with https://github.com/LibreDWG/libredwg/issues/870#issuecomment-1825470525 ? I need blank.dwg (Open AutoCAD and save to blank.DWG file) files from new AutoCAD releases.

michal-josef-spacek commented 10 months ago

865 with modifications was merged, but there are errors still. In progress.

timoria21 commented 9 months ago

Guys in this ticket :-), could you help me with #870 (comment) ? I need blank.dwg (Open AutoCAD and save to blank.DWG file) files from new AutoCAD releases.

I don't see any more progress here. Do you need more DWG test files from me?

michal-josef-spacek commented 9 months ago

@timoria21 In the case of #870 I haven't data. If you have some, I am open to processing it. I found that service packs have their own version. I am thinking about the implementation of known and unknown AutoCAD versions. It is doable.

timoria21 commented 9 months ago

Can you confirm that for some file formats, the problem is resolved? It would be great to have at least a few file formats without the "recovery mode" issue...