TclCommandOpenGCode.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from tclCommands.TclCommand import *
  2. class TclCommandOpenGCode(TclCommandSignaled):
  3. """
  4. Tcl shell command to open a G-Code file.
  5. """
  6. # array of all command aliases, to be able use old names for
  7. # backward compatibility (add_poly, add_polygon)
  8. aliases = ['open_gcode']
  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. ('outname', str)
  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': "Opens a G-Code file.",
  24. 'args': collections.OrderedDict([
  25. ('filename', 'Path to file to open.'),
  26. ('outname', 'Name of the resulting CNCJob object.')
  27. ]),
  28. 'examples': []
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. execute current TCL shell command
  33. :param args: array of known named arguments and options
  34. :param unnamed_args: array of other values which were passed into command
  35. without -somename and we do not have them in known arg_names
  36. :return: None or exception
  37. """
  38. self.app.open_gcode(args['filename'], **args)