File dwg = new File(dwgPath);
String outFile = dwg.getAbsolutePath().replace(“.dwg”, “.dxf”);
LoadOptions loadOptions = new LoadOptions();
loadOptions.setSpecifiedEncoding(CodePages.SimpChinese);
CadImage cadImage = (CadImage) Image.load(dwgPath, loadOptions);
cadImage.save(outFile);
cadImage.close();
When I use version 20.9, the conversion of DXF is successful, but when I open the DXF file using gdal, it throws an exception when reading the data under AcDbSplit in the DXF file.
When upgrading aspose.cad to the latest version 24.3, the conversion of dwg to dxf fails with the following exception:
Exception in thread “main” com.aspose.cad.internal.Exceptions.NullReferenceException: Object reference not set to an instance of an object.
at com.aspose.cad.internal.fa.a.a(Unknown Source)
at com.aspose.cad.internal.fa.a.b(Unknown Source)
at com.aspose.cad.internal.fa.a.c(Unknown Source)
at com.aspose.cad.fileformats.cad.CadImage.c(Unknown Source)
at com.aspose.cad.DataStreamSupporter.a(Unknown Source)
at com.aspose.cad.DataStreamSupporter.save(Unknown Source)