📜 ⬆️ ⬇️

Exporting a drawing from 2D Compass to SVG

In " Drawings in SVG format. Part 1 - Standard draft (updated) " shows an example of the drawing object model, setting the scale and line styles.
Based on the basic principles of drawing, for Compass 2D, a test alpha version of the SVG export library was created.

The library works in version Compass-graph 9 and above. It connects like all regular libraries.
archive with library and test case

The list of features provided:

Test drawing file, more than 3000 elements.


')
When exporting, the following parameters are selected:

You can display all the thin lines.

Comparative table of file size in different formats
FileResult, byte
Drawing.cdw (Compass 9)182,828
Zip file with Drawing.cdw (Compass schedule 9)69,274
The result of exporting file Drawing.cdw to unnamet.svg306,678
Zip file with unnamet.svg55 763
Raster file in .PNG format57 384
Note: When exporting, comments were entered and the class for the elements was specified as “line-type-1” instead of short “lt1”. For Compass, the latest version was not used.

In the test, there are no graphic elements like dimensions and other complex elements of the drawing for a complete comparison of the sizes of the binary and text files for the description of the drawing. But it can already be seen that the SVG text format is not so bad. When describing a drawing in the format of a function, JavaScript can significantly shorten a text file and not yield to a binary one.

Source: https://habr.com/ru/post/187026/


All Articles