TclCommandExportSVG.py 1.5 KB

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