TclCommandNewGerber.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. from ObjectCollection import *
  2. from tclCommands.TclCommand import TclCommandSignaled
  3. class TclCommandNewGerber(TclCommandSignaled):
  4. """
  5. Tcl shell command to subtract polygon from the given Geometry object.
  6. """
  7. # array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  8. aliases = ['new_gerber']
  9. # Dictionary of types from Tcl command, needs to be ordered.
  10. # For positional arguments
  11. arg_names = collections.OrderedDict([
  12. ('name', 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 = []
  20. # structured help for current command, args needs to be ordered
  21. help = {
  22. 'main': "Creates a new empty Gerber object.",
  23. 'args': collections.OrderedDict([
  24. ('name', 'New object name.'),
  25. ]),
  26. 'examples': []
  27. }
  28. def execute(self, args, unnamed_args):
  29. """
  30. execute current TCL shell command
  31. :param args: array of known named arguments and options
  32. :param unnamed_args: array of other values which were passed into command
  33. without -somename and we do not have them in known arg_names
  34. :return: None or exception
  35. """
  36. if 'name' in args:
  37. name = args['name']
  38. else:
  39. name = 'new_grb'
  40. def initialize(grb_obj, self):
  41. grb_obj.multitool = False
  42. grb_obj.source_file = []
  43. grb_obj.multigeo = False
  44. grb_obj.follow = False
  45. grb_obj.apertures = {}
  46. grb_obj.solid_geometry = []
  47. try:
  48. grb_obj.options['xmin'] = 0
  49. grb_obj.options['ymin'] = 0
  50. grb_obj.options['xmax'] = 0
  51. grb_obj.options['ymax'] = 0
  52. except KeyError:
  53. pass
  54. self.app.new_object('gerber', name, initialize, plot=False)