Corrupt dwg file

Hi,

I am currently working on a code that will automate the modification of dwg drawings including adding blocks and attributes. I am using the Aspose.CAD free library in C# and I am trying to edit the .dwg file. The issue is that every time I save my file, when I try to re-open it, the file is corrupt. This problem happens when I modify the file but it also happens when I only open and save it without any modification.

My code:
using Aspose.CAD;
using Aspose.CAD.FileFormats.Cad;

public abstract class EditCad
{
    public static void addLine(string path)
    {
        using (CadImage cadImage = (CadImage)Image.Load(path))
        {
            cadImage.Save("mypath/test.dwg");
        }
    }
 }

Thank you!

@SamCroteau,
Hello.
Could you please attach sample DWG file (one or few, probably, there are different issues there), so we can reproduce the problem on our side and fix them?

Hi,
To put more context, I use BricsCAD V22.2.05.
So I created an empty file (empty.dwg) and I tried my code and obtained the file empty_output.dwg which is now corrupt.

I also tried to create a new file and then added some lines directly in BricsCAD and run my code and I obtained a corrupt file as well.

dwg_files.zip (97,9 Ko)

Thank you!

@SamCroteau,
thank you, we have created CADNET-9840 to investigate and fix this issue.