From 679b33fa720957b90a867f198023c2ef17dfaec5 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 16 Feb 2019 01:52:20 +0200 Subject: [PATCH] - updated the Excellon plot function so it can plot the Excellon's from old projects - removed the message boxes that popup on Excellon Export errors and replaced them with status bar messages --- FlatCAMApp.py | 19 ++++--------------- FlatCAMObj.py | 44 +++++++++++++++++++++++--------------------- README.md | 2 ++ 3 files changed, 29 insertions(+), 36 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 1e03915b..496bd016 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -4978,23 +4978,12 @@ class App(QtCore.QObject): obj = self.collection.get_active() if obj is None: - self.inform.emit("[WARNING_NOTCL] No object selected.") - msg = "Please Select an Excellon object to export" - msgbox = QtWidgets.QMessageBox() - msgbox.setInformativeText(msg) - msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - msgbox.exec_() + self.inform.emit("[WARNING_NOTCL] No object selected. Please Select an Excellon object to export.") return # Check for more compatible types and add as required if not isinstance(obj, FlatCAMExcellon): - msg = "[WARNING_NOTCL] Only Excellon objects can be used." - msgbox = QtWidgets.QMessageBox() - msgbox.setInformativeText(msg) - msgbox.setStandardButtons(QtWidgets.QMessageBox.Ok) - msgbox.setDefaultButton(QtWidgets.QMessageBox.Ok) - msgbox.exec_() + self.inform.emit("[ERROR_NOTCL] Failed. Only Excellon objects can be saved as Excellon files...") return name = self.collection.get_active().options["name"] @@ -6105,7 +6094,7 @@ class App(QtCore.QObject): App.log.debug(obj['kind'] + ": " + obj['options']['name']) self.new_object(obj['kind'], obj['options']['name'], obj_init, active=False, fit=False, plot=True) - # self.plot_all() + self.plot_all() self.inform.emit("[success] Project loaded from: " + filename) self.should_we_save = False @@ -6807,7 +6796,7 @@ The normal flow when working in FlatCAM is the following:

json.dump(d, f, default=to_dict, indent=2, sort_keys=True) f.close() - # verification of the saved project + # verification of the saved project # Open and parse try: saved_f = open(filename, 'r') diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 45ffc616..34ff30db 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -2226,29 +2226,31 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.add_shape(shape=ints, color='green', visible=self.options['plot']) self.shapes.redraw() - except (ObjectDeleted, AttributeError): + return + except (ObjectDeleted, AttributeError, KeyError): self.shapes.clear(update=True) - # try: - # _ = iter(self.solid_geometry) - # except TypeError: - # self.solid_geometry = [self.solid_geometry] - # - # try: - # # Plot excellon (All polygons?) - # if self.options["solid"]: - # for geo in self.solid_geometry: - # self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'], - # layer=2) - # else: - # for geo in self.solid_geometry: - # self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot']) - # for ints in geo.interiors: - # self.add_shape(shape=ints, color='green', visible=self.options['plot']) - # - # self.shapes.redraw() - # except (ObjectDeleted, AttributeError): - # self.shapes.clear(update=True) + # this stays for compatibility reasons, in case we try to open old projects + try: + _ = iter(self.solid_geometry) + except TypeError: + self.solid_geometry = [self.solid_geometry] + + try: + # Plot excellon (All polygons?) + if self.options["solid"]: + for geo in self.solid_geometry: + self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'], + layer=2) + else: + for geo in self.solid_geometry: + self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot']) + for ints in geo.interiors: + self.add_shape(shape=ints, color='green', visible=self.options['plot']) + + self.shapes.redraw() + except (ObjectDeleted, AttributeError): + self.shapes.clear(update=True) # try: # # Plot excellon (All polygons?) diff --git a/README.md b/README.md index 475c36fa..5fbfec48 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ CAD program, and create G-Code for Isolation routing. - remade the Excellon export function to work with parameters entered in Edit -> Preferences -> Excellon Export - added a new entry in the Project Context Menu named 'Save'. It will actually work for Geometry and it will do Export DXF and for Excellon and it will do Export Excellon - reworked the offer to save a project so it is done only if there are objects in the project but those objects are new and/or are modified since last project load (if an old project was loaded.) +- updated the Excellon plot function so it can plot the Excellon's from old projects +- removed the message boxes that popup on Excellon Export errors and replaced them with status bar messages 14.02.2019