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 caseThe list of features provided:
- document type - drawing standard or non-standard format,
- default styling only - Design Drawing. First sheet
- export of species with indication of color and scale
- exporting layers with color
- export of graphic elements: line, arc, circle, point, NURBS, ellipse, rectangle, polyline.
Test drawing file, more than 3000 elements.

')
When exporting, the following parameters are selected:
- black (black and white)
- set for view (view color used)
- set for layer (layer color is used)
- set for the object (as usually displayed in the Compass schedule)
You can display all the thin lines.
Comparative table of file size in different formats
File | Result, 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.svg | 306,678 |
Zip file with unnamet.svg | 55 763 |
Raster file in .PNG format | 57 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.