2019-01-03 19:25:08 +00:00
|
|
|
from tclCommands.TclCommand import TclCommand
|
|
|
|
|
2019-10-24 23:10:52 +00:00
|
|
|
import collections
|
2020-04-13 16:15:20 +00:00
|
|
|
from copy import copy
|
2019-10-24 23:10:52 +00:00
|
|
|
|
2019-01-03 19:25:08 +00:00
|
|
|
|
|
|
|
class TclCommandExportSVG(TclCommand):
|
|
|
|
"""
|
|
|
|
Tcl shell command to export a Geometry Object as an SVG File.
|
|
|
|
|
|
|
|
example:
|
|
|
|
export_svg my_geometry filename
|
|
|
|
"""
|
|
|
|
|
|
|
|
# List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
|
|
|
|
aliases = ['export_svg']
|
|
|
|
|
2020-04-13 16:15:20 +00:00
|
|
|
description = '%s %s' % ("--", "Export a Geometry object as a SVG File.")
|
|
|
|
|
2019-01-03 19:25:08 +00:00
|
|
|
# Dictionary of types from Tcl command, needs to be ordered
|
|
|
|
arg_names = collections.OrderedDict([
|
|
|
|
('name', str),
|
|
|
|
('filename', str),
|
|
|
|
('scale_factor', float)
|
|
|
|
])
|
|
|
|
|
|
|
|
# Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
|
|
|
|
option_types = collections.OrderedDict([
|
|
|
|
('scale_factor', float)
|
|
|
|
])
|
|
|
|
|
|
|
|
# array of mandatory options for current Tcl command: required = {'name','outname'}
|
|
|
|
required = ['name']
|
|
|
|
|
|
|
|
# structured help for current command, args needs to be ordered
|
|
|
|
help = {
|
2020-04-13 16:15:20 +00:00
|
|
|
'main': "Export a Geometry object as a SVG File.",
|
2019-01-03 19:25:08 +00:00
|
|
|
'args': collections.OrderedDict([
|
2020-04-09 01:13:04 +00:00
|
|
|
('name', 'Name of the object export. Required.'),
|
2020-04-13 16:15:20 +00:00
|
|
|
('filename', 'Absolute path to file to export.\n'
|
|
|
|
'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
|
2019-01-03 19:25:08 +00:00
|
|
|
('scale_factor', 'Multiplication factor used for scaling line widths during export.')
|
|
|
|
]),
|
|
|
|
'examples': ['export_svg my_geometry my_file.svg']
|
|
|
|
}
|
|
|
|
|
|
|
|
def execute(self, args, unnamed_args):
|
|
|
|
"""
|
|
|
|
|
|
|
|
:param args:
|
|
|
|
:param unnamed_args:
|
|
|
|
:return:
|
|
|
|
"""
|
|
|
|
|
|
|
|
self.app.export_svg(**args)
|