Convert from dwg to dxfr

    Hi.     

I am trying to convert from dwg to dxf but i am getting error - Object reference not set to an instance of an object
I’m using c# function

public static string DwgToDxf(string filename)
{
string extension = Path.GetExtension(filename);
if (extension == “dxf”)
return filename;

Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(filename);
var file = Path.GetFileNameWithoutExtension(Path.GetRandomFileName());
string DxfFilePath = Path.Combine(Path.GetTempPath(), file + ".dxf");
cadImage.Save(DxfFilePath);
return DxfFilePath;

}
dwg file: THE_plants_bible.dwg - Google Drive

@Aleks85
Hi.
I guess you need to use cadImage.Save(DxfFilePath, new DxfOptions()) with options to change file format, but it does not work too at the moment.

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): CADNET-9277

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi,

I’m facing the same problem too, may I know if the issue is fixed? I’m using asposeCAD for java 23.8.

Thanks!

@weitz001,
Hi,
could you please provide your test file, so we can check the source of the problem for it.

asposeCAD2.zip (2.8 MB)

Sure, please refer to the attachment, 4 files were included:

program: asposeCAD.java
dwg file: example.dwg
maven pom: pom.xml

@weitz001,
Thank you, we will check it and I will come back with new information later. As a note - I have edited your previous post and attachment so it does not contain license file.

Oops! my fault, thank you!

@weitz001,
options are required for changing format, and this example works:

CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setPageWidth(1000);
rasterizationOptions.setPageHeight(1000);

DxfOptions dxfOptions = new DxfOptions();
dxfOptions.setVectorRasterizationOptions(rasterizationOptions);

cadImage.save(dxfName, dxfOptions);

But it seems the resulting DXF can not be opened properly, so we created CADJAVA-11340 to investigate and fix this issue.

Wow! this is the way to cast CadRasterizationOptions to ImageOptionsBase! I tried many ways but failed all the time! that’s why I only put “path” in save() method.

I guess this is the issue from later libery right? is there an old version libery can covert normally? also how can I get the license for the old version?

thanks!

@weitz001,
I guess previous versions have this issue with saving to DXF too. You can try to use current license for some previous version too. We will look at the reason in the scope of the task above.