diff --git a/CHANGELOG.md b/CHANGELOG.md index 330bb833..e7e9b48d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,8 @@ CHANGELOG for FlatCAM Evo beta - fixed some bugs in the Punch Gerber plugin - fixed some bugs where the 'pool' parameter was not passed when creating shapes collections (in 3D graphic mode); I wonder how it worked until now - added a new feature in the Isolation Plugin: now for all the isolation Geometry objects this plugin can do a supplementary simplification of the geometry using the tolerance parameter defined in the General Parameters. This should lead to a reduced number of tool lifts when doing corners +- fixed aperture marking in Extract Plugin +- in Extract Plugin if no Gerber object is selected then the first Gerber object in the project list is selected (if any) 30.03.2022 diff --git a/appObjects/GerberObject.py b/appObjects/GerberObject.py index 543e994a..cac0eaeb 100644 --- a/appObjects/GerberObject.py +++ b/appObjects/GerberObject.py @@ -1038,19 +1038,20 @@ class GerberObject(FlatCAMObj, Gerber): def job_thread(app_obj): with self.app.proc_container.new('%s ...' % _("Plotting")): try: - if aperture_to_plot_mark in self.tools: + if aperture_to_plot_mark in app_obj.tools: for elem in app_obj.tools[aperture_to_plot_mark]['geometry']: if 'solid' in elem: if only_flashes and not isinstance(elem['follow'], Point): continue geo = elem['solid'] + s_geo = geo.geoms if isinstance(geo, (MultiLineString, MultiPolygon)) else geo try: - for el in geo: + for el in s_geo: shape_key = app_obj.add_mark_shape(shape=el, color=color, face_color=color, visible=visibility) app_obj.mark_shapes_storage[aperture_to_plot_mark].append(shape_key) except TypeError: - shape_key = app_obj.add_mark_shape(shape=geo, color=color, face_color=color, + shape_key = app_obj.add_mark_shape(shape=s_geo, color=color, face_color=color, visible=visibility) app_obj.mark_shapes_storage[aperture_to_plot_mark].append(shape_key) app_obj.mark_shapes.redraw() diff --git a/appPlugins/ToolExtract.py b/appPlugins/ToolExtract.py index f0d8ba45..173b550f 100644 --- a/appPlugins/ToolExtract.py +++ b/appPlugins/ToolExtract.py @@ -124,7 +124,8 @@ class ToolExtract(AppTool): self.set_tool_ui() self.build_tool_ui() - self.app.ui.notebook.setTabText(2, _("Extract")) + # trigger this once at plugin launch + self.on_object_combo_changed() def connect_signals_at_init(self): # ## Signals @@ -207,9 +208,18 @@ class ToolExtract(AppTool): # SELECT THE CURRENT OBJECT obj = self.app.collection.get_active() - if obj and obj.kind == 'gerber': - obj_name = obj.obj_options['name'] - self.ui.gerber_object_combo.set_value(obj_name) + if obj: + if obj.kind == 'gerber': + obj_name = obj.obj_options['name'] + self.ui.gerber_object_combo.set_value(obj_name) + else: + # take first available Gerber file, if any + available_gerber_list = [o for o in self.app.collection.get_list() if o.kind == 'gerber'] + if available_gerber_list: + obj_name = available_gerber_list[0].obj_options['name'] + self.ui.gerber_object_combo.set_value(obj_name) + + self.app.ui.notebook.setTabText(2, _("Extract")) def build_tool_ui(self): self.ui_disconnect() @@ -330,6 +340,17 @@ class ToolExtract(AppTool): # self.ui.apertures_table.setMinimumHeight(self.ui.apertures_table.getHeight()) # self.ui.apertures_table.setMaximumHeight(self.ui.apertures_table.getHeight()) + # make sure you clear the Gerber aperture markings when the table is rebuilt + # get the Gerber file who is the source of the punched Gerber + selection_index = self.ui.gerber_object_combo.currentIndex() + model_index = self.app.collection.index(selection_index, 0, self.ui.gerber_object_combo.rootModelIndex()) + try: + grb_obj = model_index.internalPointer().obj + except Exception: + self.ui_connect() + return + grb_obj.clear_plot_apertures() + self.ui_connect() def ui_connect(self):