TclCommandExportSVG.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. from tclCommands.TclCommand import TclCommand
  2. import collections
  3. class TclCommandExportSVG(TclCommand):
  4. """
  5. Tcl shell command to export a Geometry Object as an SVG File.
  6. example:
  7. export_svg my_geometry filename
  8. """
  9. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  10. aliases = ['export_svg']
  11. description = '%s %s' % ("--", "Export a Geometry object as a SVG File.")
  12. # Dictionary of types from Tcl command, needs to be ordered
  13. arg_names = collections.OrderedDict([
  14. ('name', str),
  15. ('filename', str),
  16. ('scale_stroke_factor', float)
  17. ])
  18. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  19. option_types = collections.OrderedDict([
  20. ('scale_stroke_factor', float)
  21. ])
  22. # array of mandatory options for current Tcl command: required = {'name','outname'}
  23. required = ['name']
  24. # structured help for current command, args needs to be ordered
  25. help = {
  26. 'main': "Export a Geometry object as a SVG File.",
  27. 'args': collections.OrderedDict([
  28. ('name', 'Name of the object export. Required.'),
  29. ('filename', 'Absolute path to file to export.\n'
  30. 'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
  31. ('scale_stroke_factor', 'Multiplication factor used for scaling line widths during export.')
  32. ]),
  33. 'examples': ['export_svg my_geometry my_file.svg']
  34. }
  35. def execute(self, args, unnamed_args):
  36. """
  37. :param args:
  38. :param unnamed_args:
  39. :return:
  40. """
  41. self.app.f_handlers.export_svg(**args)