TclCommandNewGerber.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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 ObjectCollection import *
  8. from tclCommands.TclCommand import TclCommandSignaled
  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. # Dictionary of types from Tcl command, needs to be ordered.
  16. # For positional arguments
  17. arg_names = collections.OrderedDict([
  18. ('name', str)
  19. ])
  20. # Dictionary of types from Tcl command, needs to be ordered.
  21. # For options like -optionname value
  22. option_types = collections.OrderedDict([
  23. ])
  24. # array of mandatory options for current Tcl command: required = {'name','outname'}
  25. required = []
  26. # structured help for current command, args needs to be ordered
  27. help = {
  28. 'main': "Creates a new empty Gerber object.",
  29. 'args': collections.OrderedDict([
  30. ('name', 'New object name.'),
  31. ]),
  32. 'examples': []
  33. }
  34. def execute(self, args, unnamed_args):
  35. """
  36. execute current TCL shell command
  37. :param args: array of known named arguments and options
  38. :param unnamed_args: array of other values which were passed into command
  39. without -somename and we do not have them in known arg_names
  40. :return: None or exception
  41. """
  42. if 'name' in args:
  43. name = args['name']
  44. else:
  45. name = 'new_grb'
  46. def initialize(grb_obj, self):
  47. grb_obj.multitool = False
  48. grb_obj.source_file = []
  49. grb_obj.multigeo = False
  50. grb_obj.follow = False
  51. grb_obj.apertures = {}
  52. grb_obj.solid_geometry = []
  53. try:
  54. grb_obj.options['xmin'] = 0
  55. grb_obj.options['ymin'] = 0
  56. grb_obj.options['xmax'] = 0
  57. grb_obj.options['ymax'] = 0
  58. except KeyError:
  59. pass
  60. self.app.new_object('gerber', name, initialize, plot=False)