when exporting SVG, map user units to mm so the coordinates make sense

This commit changes SVG export so that the user unit (what SVG calls
'px') is defined to be 1 mm.

This lets us write out the native sketch coordinates in the SVG file,
and the SVG will contain a drawing of the correct size (same size as
what's in FreeCAD).
This commit is contained in:
Sebastian Kuzminsky
2012-02-09 09:03:19 -07:00
parent 67b3c28990
commit 60c61a3f6d

View File

@@ -961,12 +961,14 @@ def export(exportList,filename):
boty = sizey+miny
# writing header
# we specify the svg width and height in FreeCAD's physical units (mm),
# and specify the viewBox so that user units maps one-to-one to mm
svg = pythonopen(filename,'wb')
svg.write('<?xml version="1.0"?>\n')
svg.write('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"')
svg.write(' "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')
svg.write('<svg')
svg.write(' width="' + str(sizex) + '" height="' + str(sizey) + '"')
svg.write(' width="' + str(sizex) + 'mm" height="' + str(sizey) + 'mm"')
svg.write(' viewBox="0 0 ' + str(sizex) + ' ' + str(sizey) + '"')
svg.write(' xmlns="http://www.w3.org/2000/svg" version="1.1"')
svg.write('>\n')