diff --git a/README.md b/README.md index a59f5946..156a97fe 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing. - Gerber Editor: added shortcut for Transform Tool and also toggle effect here, too - updated the shortcut list with the Gerber Editor shortcut keys - Gerber Editor: fixed error when adding an aperture with code value lower than the ones that already exists +- when adding an aperture with code '0' (zero) it will automatically be set with size zero and type: 'REG' (from region); here we store all the regions from a Gerber file, the ones without a declared aperture 11.04.2019 diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py index 11175096..0f91349d 100644 --- a/flatcamEditors/FlatCAMGrbEditor.py +++ b/flatcamEditors/FlatCAMGrbEditor.py @@ -1541,50 +1541,65 @@ class FlatCAMGrbEditor(QtCore.QObject): "Add it and retry.")) return - if ap_id not in self.olddia_newdia: - self.storage_dict[ap_id] = {} + if ap_id == '0': + if ap_id not in self.olddia_newdia: + self.storage_dict[ap_id] = {} + self.storage_dict[ap_id]['type'] = 'REG' + size_val = 0 + self.apsize_entry.set_value(size_val) + self.storage_dict[ap_id]['size'] = size_val - type_val = self.aptype_cb.currentText() - self.storage_dict[ap_id]['type'] = type_val + self.storage_dict[ap_id]['solid_geometry'] = [] + self.storage_dict[ap_id]['follow_geometry'] = [] - if type_val == 'R' or type_val == 'O': - try: - dims = self.apdim_entry.get_value() - self.storage_dict[ap_id]['width'] = dims[0] - self.storage_dict[ap_id]['height'] = dims[1] - - size_val = math.sqrt((dims[0] ** 2) + (dims[1] ** 2)) - self.apsize_entry.set_value(size_val) - - except Exception as e: - log.error("FlatCAMGrbEditor.on_aperture_add() --> the R or O aperture dims has to be in a " - "tuple format (x,y)\nError: %s" % str(e)) - self.app.inform.emit(_("[WARNING_NOTCL] Aperture dimensions value is missing or wrong format. " - "Add it in format (width, height) and retry.")) - return - else: - try: - size_val = float(self.apsize_entry.get_value()) - except ValueError: - # try to convert comma to decimal point. if it's still not working error message and return - try: - size_val = float(self.apsize_entry.get_value().replace(',', '.')) - self.apsize_entry.set_value(size_val) - except ValueError: - self.app.inform.emit(_("[WARNING_NOTCL] Aperture size value is missing or wrong format. " - "Add it and retry.")) - return - self.storage_dict[ap_id]['size'] = size_val - - self.storage_dict[ap_id]['solid_geometry'] = [] - self.storage_dict[ap_id]['follow_geometry'] = [] - - # self.olddia_newdia dict keeps the evidence on current aperture codes as keys and gets updated on values - # each time a aperture code is edited or added - self.olddia_newdia[ap_id] = ap_id + # self.olddia_newdia dict keeps the evidence on current aperture codes as keys and gets updated on values + # each time a aperture code is edited or added + self.olddia_newdia[ap_id] = ap_id else: - self.app.inform.emit(_("[WARNING_NOTCL] Aperture already in the aperture table.")) - return + if ap_id not in self.olddia_newdia: + self.storage_dict[ap_id] = {} + + type_val = self.aptype_cb.currentText() + self.storage_dict[ap_id]['type'] = type_val + + if type_val == 'R' or type_val == 'O': + try: + dims = self.apdim_entry.get_value() + self.storage_dict[ap_id]['width'] = dims[0] + self.storage_dict[ap_id]['height'] = dims[1] + + size_val = math.sqrt((dims[0] ** 2) + (dims[1] ** 2)) + self.apsize_entry.set_value(size_val) + + except Exception as e: + log.error("FlatCAMGrbEditor.on_aperture_add() --> the R or O aperture dims has to be in a " + "tuple format (x,y)\nError: %s" % str(e)) + self.app.inform.emit(_("[WARNING_NOTCL] Aperture dimensions value is missing or wrong format. " + "Add it in format (width, height) and retry.")) + return + else: + try: + size_val = float(self.apsize_entry.get_value()) + except ValueError: + # try to convert comma to decimal point. if it's still not working error message and return + try: + size_val = float(self.apsize_entry.get_value().replace(',', '.')) + self.apsize_entry.set_value(size_val) + except ValueError: + self.app.inform.emit(_("[WARNING_NOTCL] Aperture size value is missing or wrong format. " + "Add it and retry.")) + return + self.storage_dict[ap_id]['size'] = size_val + + self.storage_dict[ap_id]['solid_geometry'] = [] + self.storage_dict[ap_id]['follow_geometry'] = [] + + # self.olddia_newdia dict keeps the evidence on current aperture codes as keys and gets updated on values + # each time a aperture code is edited or added + self.olddia_newdia[ap_id] = ap_id + else: + self.app.inform.emit(_("[WARNING_NOTCL] Aperture already in the aperture table.")) + return # since we add a new tool, we update also the initial state of the tool_table through it's dictionary # we add a new entry in the tool2tooldia dict