TclCommandExportSVG.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommand
  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. # Dictionary of types from Tcl command, needs to be ordered
  12. arg_names = collections.OrderedDict([
  13. ('name', str),
  14. ('filename', str),
  15. ('scale_factor', float)
  16. ])
  17. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  18. option_types = collections.OrderedDict([
  19. ('scale_factor', float)
  20. ])
  21. # array of mandatory options for current Tcl command: required = {'name','outname'}
  22. required = ['name']
  23. # structured help for current command, args needs to be ordered
  24. help = {
  25. 'main': "Export a Geometry Object as a SVG File.",
  26. 'args': collections.OrderedDict([
  27. ('name', 'Name of the object export.'),
  28. ('filename', 'Path to the file to export.'),
  29. ('scale_factor', 'Multiplication factor used for scaling line widths during export.')
  30. ]),
  31. 'examples': ['export_svg my_geometry my_file.svg']
  32. }
  33. def execute(self, args, unnamed_args):
  34. """
  35. :param args:
  36. :param unnamed_args:
  37. :return:
  38. """
  39. name = args['name']
  40. self.app.export_svg(**args)