TclCommandOpenGCode.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommandSignaled
  3. class TclCommandOpenGCode(TclCommandSignaled):
  4. """
  5. Tcl shell command to open a G-Code file.
  6. """
  7. # array of all command aliases, to be able use old names for
  8. # backward compatibility (add_poly, add_polygon)
  9. aliases = ['open_gcode']
  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. ('outname', str)
  19. ])
  20. # array of mandatory options for current Tcl command: required = {'name','outname'}
  21. required = ['filename']
  22. # structured help for current command, args needs to be ordered
  23. help = {
  24. 'main': "Opens a G-Code file.",
  25. 'args': collections.OrderedDict([
  26. ('filename', 'Path to file to open.'),
  27. ('outname', 'Name of the resulting CNCJob object.')
  28. ]),
  29. 'examples': []
  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.open_gcode(args['filename'], **args)