DomCR / ACadSharp

C# library to read/write cad files like dxf/dwg.
MIT License
386 stars 111 forks source link

DWG MText Not Appearing #378

Closed KyleeChangg closed 1 month ago

KyleeChangg commented 1 month ago

Describe the bug MText does not appear in rewritten DWG file.

To Reproduce

static void Main(string[] args)
 {
     string inputPath = @"Redacted";
     // Asynchronously read the DWG file
     Thread readThread = new Thread(() => ReadDWG(inputPath));
     readThread.Start();

     // Wait for the read to complete
     readCompleteEvent.WaitOne();

     //UpdateTextValues(doc);
     // Proceed with writing the DWG file
     WriteDWG(outputPath);
 }

 private static void ReadDWG(string path)
 {
     try
     {
         doc = DwgReader.Read(path);

     }
     finally
     {
         DwgWriter.Write("Mod.dwg", doc);
         readCompleteEvent.Set(); // Signal that reading is complete
     }
 }

 private static void WriteDWG(string path)
 {
     DwgWriter.Write("Mod.dwg", doc);
     Console.WriteLine("DWG file saved successfully.");
 }

Expected behavior In my newly written DWG file, it seems that all MText entities in the original file have disappeared.

Screenshots Screenshot 2024-07-14 142034

Screenshot 2024-07-14 142016
DomCR commented 1 month ago

Hi @KyleeChangg,

I've been looking at the issue, it seems that for versions superiors than AC1027 the none Annotative text writer does not work properly, I'll open a branch to fix this issue, in the meantime you can try to set the IsAnnotative flag to true or change the version to AC1018.

Thanks!