TclCommandSaveProject.py 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from tclCommands.TclCommand import TclCommandSignaled
  2. import collections
  3. class TclCommandSaveProject(TclCommandSignaled):
  4. """
  5. Tcl shell command to save the FlatCAM project to file.
  6. """
  7. # array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  8. aliases = ['save_project']
  9. # Dictionary of types from Tcl command, needs to be ordered.
  10. # For positional arguments
  11. arg_names = collections.OrderedDict([
  12. ('filename', str)
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered.
  15. # For options like -optionname value
  16. option_types = collections.OrderedDict([
  17. ])
  18. # array of mandatory options for current Tcl command: required = {'name','outname'}
  19. required = ['filename']
  20. # structured help for current command, args needs to be ordered
  21. help = {
  22. 'main': "Saves the FlatCAM project to file.",
  23. 'args': collections.OrderedDict([
  24. ('filename', 'Absolute path to file to open. Required.\n'
  25. 'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
  26. ]),
  27. 'examples': ['save_project D:\\my_project_file.FlatPrj',
  28. 'save_project "D:\\my_project_file with spaces in the name.FlatPrj"',
  29. 'save_project path_to_where_the_file_is_stored']
  30. }
  31. def execute(self, args, unnamed_args):
  32. """
  33. execute current TCL shell command
  34. :param args: array of known named arguments and options
  35. :param unnamed_args: array of other values which were passed into command
  36. without -somename and we do not have them in known arg_names
  37. :return: None or exception
  38. """
  39. self.app.save_project(args['filename'])