TclCommandSaveProject.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. description = '%s %s' % ("--", "Saves the FlatCAM project to file.")
  10. # Dictionary of types from Tcl command, needs to be ordered.
  11. # For positional arguments
  12. arg_names = collections.OrderedDict([
  13. ('filename', str)
  14. ])
  15. # Dictionary of types from Tcl command, needs to be ordered.
  16. # 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 = ['filename']
  21. # structured help for current command, args needs to be ordered
  22. help = {
  23. 'main': "Saves the FlatCAM project to file.",
  24. 'args': collections.OrderedDict([
  25. ('filename', 'Absolute path to file to save. Required.\n'
  26. 'WARNING: no spaces are allowed. If unsure enclose the entire path with quotes.'),
  27. ]),
  28. 'examples': ['save_project D:\\my_project_file.FlatPrj',
  29. 'save_project "D:\\my_project_file with spaces in the name.FlatPrj"',
  30. 'save_project path_to_where_the_file_is_stored']
  31. }
  32. def execute(self, args, unnamed_args):
  33. """
  34. execute current TCL shell command
  35. :param args: array of known named arguments and options
  36. :param unnamed_args: array of other values which were passed into command
  37. without -somename and we do not have them in known arg_names
  38. :return: None or exception
  39. """
  40. self.app.save_project(args['filename'], from_tcl=True)