Hello, I have an example dwg file. This file does not contain named layers.
When I try to load it by
Image objImage = Image.load(sourceFilePath);
I got the error:
Exception in thread “main” class com.aspose.cad.cadexceptions.ImageLoadException: Image loading failed. —> class com.aspose.cad.cadexceptions.imageformats.CadException: File is incompatible with exporter, please try to convert it to Dxf: R12/R2007/R2010 or Dwg: R13/R14/R2000/R2004/R2007/R2010/R2013/R2014/R2015/R2018
com.aspose.cad.internal.eK.a.b(Unknown Source)
com.aspose.cad.fileformats.cad.CadImage.a(Unknown Source)
com.aspose.cad.fileformats.cad.CadImage.setLayers(Unknown Source)
com.aspose.cad.internal.fw.bc.load(Unknown Source)
com.aspose.cad.Image.a(Unknown Source)
com.aspose.cad.Image.load(Unknown Source)
the error caused this check:
if (var3.getLayerName() == null) {
throw (new com.aspose.cad.internal.eK.a()).b(3);
}
in the com.aspose.cad.fileformats.cad.CadImage class
dwg_with_empty_layer_name.zip (5.2 KB)
@savievg,
I have observe the stack trace shared by you and request you to please first try using the latest Aspose.CAD for Java 19.5 on your end. In case the issue is still reproduced then please share working sample code reproducing the issue on your end.
Hello, I can confirm: I use the latest version of library. Please find below the sample application that crashed with mentioned exception:
import com.aspose.cad.Image;
import com.aspose.cad.ImageOptionsBase;
import com.aspose.cad.imageoptions.*;
public class TestApp {
public static void main(String[] args) {
String sourceFilePath = args[0];
Image objImage = Image.load(sourceFilePath);
CadRasterizationOptions cadRasterizationOptions = new CadRasterizationOptions();
cadRasterizationOptions.setPageWidth(800);
cadRasterizationOptions.setPageHeight(600);
ImageOptionsBase options;
options = new JpegOptions();
options.setVectorRasterizationOptions(cadRasterizationOptions);
String outPath = sourceFilePath + ".jpg";
objImage.save(outPath, options);
}
}
You should provide the dwg file from my first message as the program argument.
@savievg,
I have worked with the DWG file shared by you and have been able to observe the issue. An issue with ID CADJAVA-495 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be fixed.
The issues you have found earlier (filed as ) have been fixed in this update.
Hello, I have tried your fix, but it does not work. Got the exception:
Exception in thread “main” class com.aspose.cad.cadexceptions.ImageLoadException: Image loading failed. —> class com.aspose.cad.cadexceptions.imageformats.CadException: The Dwg version isn’t valid. Only Dwg: R13/R14/R2000/R2004/R2007/R2010/R2013/R2014/R2015/R2018 are currently supported.
com.aspose.cad.internal.eK.a.a(Unknown Source)
com.aspose.cad.Image.a(Unknown Source)
com.aspose.cad.Image.load(Unknown Source)
TestApp.main(TestApp.java:9)
@savievg,
I regret to share that concerned issue CADJAVA-495 has not yet been resolved. We will share the good news with you as soon as it will be fixed.
@savievg
I like to inform that attached file is not a DWG file at all, it’s HTML of some download page that got saved as DWG. We have tried to retrieve the file based on what we have found in that HTML, but it seems to be a different file, as it’s layers are named and it works without problems. Can you please share the proper file for further investigation.
The issues you have found earlier (filed as CADJAVA-495) have been fixed in this update.