TclCommandJoinExcellon.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommand
  3. class TclCommandJoinExcellon(TclCommand):
  4. """
  5. Tcl shell command to merge Excellon objects.
  6. example:
  7. """
  8. # List of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  9. aliases = ['join_excellon', 'join_excellons']
  10. # Dictionary of types from Tcl command, needs to be ordered
  11. arg_names = collections.OrderedDict([
  12. ('outname', str),
  13. ])
  14. # Dictionary of types from Tcl command, needs to be ordered , this is for options like -optionname value
  15. option_types = collections.OrderedDict([
  16. ])
  17. # array of mandatory options for current Tcl command: required = {'name','outname'}
  18. required = ['outname']
  19. # structured help for current command, args needs to be ordered
  20. help = {
  21. 'main': "Runs a merge operation (join) on the Excellon objects.",
  22. 'args': collections.OrderedDict([
  23. ('name', 'Name of the new Excellon Object.'),
  24. ('obj_name_0', 'Name of the first object'),
  25. ('obj_name_1', 'Name of the second object.'),
  26. ('obj_name_2...', 'Additional object names')
  27. ]),
  28. 'examples': []
  29. }
  30. def execute(self, args, unnamed_args):
  31. """
  32. :param args:
  33. :param unnamed_args:
  34. :return:
  35. """
  36. outname = args['name']
  37. obj_names = unnamed_args
  38. objs = []
  39. for obj_n in obj_names:
  40. obj = self.app.collection.get_by_name(str(obj_n))
  41. if obj is None:
  42. return "Object not found: %s" % obj_n
  43. else:
  44. objs.append(obj)
  45. def initialize(obj_, app):
  46. FlatCAMExcellon.merge(objs, obj_)
  47. if objs is not None:
  48. self.app.new_object("excellon", outname, initialize, plot=False)