8000 When converting a DWG file to a DXF file, the Chinese characters are garbled. · Issue #622 · DomCR/ACadSharp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

When converting a DWG file to a DXF file, the Chinese characters are garbled. #622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task
tianxin8206 opened this issue Apr 21, 2025 · 10 comments · Fixed by #647
Open
1 task

When converting a DWG file to a DXF file, the Chinese characters are garbled. #622

tianxin8206 opened this issue Apr 21, 2025 · 10 comments · Fixed by #647
Labels
bug Something isn't working

Comments

@tianxin8206
Copy link
tianxin8206 commented Apr 21, 2025

Describe the bug
I read a normal DWG file and then converted it into a DXF file, but the Chinese content is displayed abnormally.

To Reproduce
My Code:

var filePath = @"D:\cad2.dwg";
var dxfFilePath = @"D:\cadfile2.dxf";

var cadDocument = DwgReader.Read(filePath);
cadDocument.Header.CodePage = "GB2312";
using var writer = new DxfWriter(dxfFilePath, cadDocument, false);
writer.Write();

Screenshots
normal:

Image

abnormal:

Image


Release needed

  • [ Y ] Yes, using the Nuget package.
  • No, using the github repo.
@tianxin8206 tianxin8206 added the bug Something isn't working label 8000 Apr 21, 2025
@DomCR
Copy link
Owner
DomCR commented Apr 23, 2025

Hi @tianxin8206,

Could you provide the file in the example to run the code on my end?

Thanks!

@tianxin8206
Copy link
Author

You can click on this link to download the file.
@DomCR

@DomCR
Copy link
Owner
DomCR commented Apr 29, 2025

The issue is related to the WidthFactor is marked as optional and is not written because there is no flag to set the WriteOptional to true.

I'll open a PR to fix it.

Thanks for the report!

@DomCR DomCR linked a pull request Apr 29, 2025 that will close this issue
@tianxin8206
Copy link
Author

@DomCR Excuse me, has this bug been fixed? I have already upgraded to version v1.1.19 and set DxfWriter.Configuration.WriteOptionalValues to true, but the converted content is still incorrect.

@DomCR
Copy link
Owner
DomCR commented May 7, 2025

Hi @tianxin8206,

I guess that you are referring to the title:
Image

If you have made changes in the text and increasing it's length, you will need to recalculate the WidthFactor or add a line break so the text doesn't overflow.

I'm sorry but this feature is not integrated in this library because it requires some external ones that provide information about the font, size...

@tianxin8206
Copy link
Author

Hi @DomCR
It's not just the title. As long as it's a conversion to Chinese characters, it will be incorrect. And I didn't perform any other operations on the file during the conversion.

@DomCR
Copy link
Owner
DomCR commented May 7, 2025

Ok, sorry for not seeing it but It's hard to notice when you don't know Chinese.

Steps:

  • You load the file and re-write it to dxf and some characters are not what they should in the output.
  • You haven't changed anything in the file, not the text, version or added some entities.

Could you give me an specific example so I can focus on the difference between both files? like 2 images, 1 with the input file and other with the output, with an specific character to look at so I can see the difference.

Sorry for asking all that 😅

@tianxin8206
Copy link
Author

Hi @DomCR
I have attached the download link for the original DWG file that needs to be converted in my previous reply. Regarding the output content, you can use the code in my first question to convert it into a DXF file, and then compare it with the original DWG file after opening it. If you have difficulty recognizing the Chinese content, you can locate the area within the red frame of the CAD drawing that I attached, and make a simple comparison with the content of the original DWG file. Alternatively, you can attach the converted content to the conversation, and I will make the judgment.

@DomCR
Copy link
Owner
DomCR commented May 7, 2025

Left is the dwg and right the dxf.

Image

I've used your code and exported the file with the block.

@DomCR
Copy link
Owner
DomCR commented May 7, 2025

Layers are not read when generating the dxf, reopening the issue.

@DomCR DomCR reopened this May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants
0