TclCommandNewGerber.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # ##########################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # File Author: Marius Adrian Stanciu (c) #
  4. # Date: 8/17/2019 #
  5. # MIT Licence #
  6. # ##########################################################
  7. from tclCommands.TclCommand import TclCommandSignaled
  8. import collections
  9. class TclCommandNewGerber(TclCommandSignaled):
  10. """
  11. Tcl shell command to subtract polygon from the given Geometry object.
  12. """
  13. # array of all command aliases, to be able use old names for backward compatibility (add_poly, add_polygon)
  14. aliases = ['new_gerber']
  15. description = '%s %s' % ("--", "Creates a new empty Gerber object.")
  16. # Dictionary of types from Tcl command, needs to be ordered.
  17. # For positional arguments
  18. arg_names = collections.OrderedDict([
  19. ('name', str)
  20. ])
  21. # Dictionary of types from Tcl command, needs to be ordered.
  22. # For options like -optionname value
  23. option_types = collections.OrderedDict([
  24. ])
  25. # array of mandatory options for current Tcl command: required = {'name','outname'}
  26. required = []
  27. # structured help for current command, args needs to be ordered
  28. help = {
  29. 'main': "Creates a new empty Gerber object.",
  30. 'args': collections.OrderedDict([
  31. ('name', 'New object name.'),
  32. ]),
  33. 'examples': ['new_gerber', 'new_gerber my_new_gerber_name']
  34. }
  35. def execute(self, args, unnamed_args):
  36. """
  37. execute current TCL shell command
  38. :param args: array of known named arguments and options
  39. :param unnamed_args: array of other values which were passed into command
  40. without -somename and we do not have them in known arg_names
  41. :return: None or exception
  42. """
  43. if 'name' in args:
  44. name = args['name']
  45. else:
  46. name = 'new_grb'
  47. def initialize(grb_obj, app_obj):
  48. grb_obj.multitool = False
  49. grb_obj.source_file = []
  50. grb_obj.multigeo = False
  51. grb_obj.follow = False
  52. grb_obj.apertures = {}
  53. grb_obj.solid_geometry = []
  54. try:
  55. grb_obj.options['xmin'] = 0
  56. grb_obj.options['ymin'] = 0
  57. grb_obj.options['xmax'] = 0
  58. grb_obj.options['ymax'] = 0
  59. except KeyError:
  60. pass
  61. self.app.new_object('gerber', name, initialize, plot=False)