[ASPOSE.CAD] svg files after exporting are too large

hi, I’m using the temporary license to check the conversion feature beforehand, when I import a dwg file (only ~500kB) and export it, I got ~15 MB SVG file, that was too large and I can’t see the whole image even when I zoom out at most.

I was looking for the document at: https://docs.aspose.com/cad/python/ but the page responded 403 Forbidden, weird things!

Now I have no idea to deal with the current problem.

Here is my code:

import aspose.cad as cad
 
lic = cad.License()
 
lic.set_license("C:\WORKPLACE\OKS\\backend\Aspose.CADforPythonvia.NET.lic")
 
image = cad.Image.load("./static/building001-0_floor1.dwg")
 
svgOptions = cad.imageoptions.SvgOptions()
image.save("DWGtoSVGoutput1.svg", svgOptions)

Please help me out! Thanks in advance!

@ntphu,
Hi.
We are sorry for the mistake with documentation URL, the correct one is Aspose.CAD for Python|Documentation, we will fix that.

Please attach the initial DWG file for the investigation so we can analyze the issue with size.

here is the dwg file I’ve already archived:
building001-0_floor1.7z (496.8 KB)

@ntphu,
could you please test if this is better:

image = cad.Image.load("building001-0_floor1.dwg")

rasterizationOptions = cad.imageoptions.CadRasterizationOptions()

rasterizationOptions.page_width = 1000.0
rasterizationOptions.page_height = 1000.0
rasterizationOptions.quality.text_thickness_normalization = True
rasterizationOptions.draw_type = cad.fileformats.cad.CadDrawTypeMode.USE_OBJECT_COLOR

svgOptions = cad.imageoptions.SvgOptions()
svgOptions.vector_rasterization_options = rasterizationOptions

image.save("DWGtoSVGoutput1.svg", svgOptions)
1 Like

thanks, it works wonderful now.

Could you explain the code, how does it work?
Where do I find these attributes and methods?

The document provided is lack of so many aspects which an actual document expected to cover.

@ntphu,
It is good idea to control size of the output canvas with setting page_width and page_height, if these options are missing, the size is calculated automatically from the drawing and could be huge (depends on the drawing). Text_thickness_normalization allows to make text looking better (sometimes it can be distorted, e.g. because of size) and draw_type option sets up the coloring of the drawing: could be fixed color or based on the colors of objects in the initial drawing. Using of another options depends on the variety of the drawings you need to process.

You can find here Aspose.CAD for Python documentation Developer Guide|Documentation and API Aspose.CAD for Python via .NET, but unfortunately there are not a lot of examples there, and you can find some use cases also from documentation for Aspose.CAD for .NET (Aspose.CAD for .NET|Documentation)

Don’t hesitate also to contact us in case of any issues and questions :slight_smile:

1 Like