diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 5fd18e02..b550d4ac 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -937,6 +937,8 @@ class App(QtCore.QObject): self.ui.menuedit_convertjoin.triggered.connect(self.on_edit_join) self.ui.menuedit_convertjoinexc.triggered.connect(self.on_edit_join_exc) + self.ui.menuedit_convertjoingrb.triggered.connect(self.on_edit_join_grb) + self.ui.menuedit_convert_sg2mg.triggered.connect(self.on_convert_singlegeo_to_multigeo) self.ui.menuedit_convert_mg2sg.triggered.connect(self.on_convert_multigeo_to_singlegeo) @@ -2485,6 +2487,25 @@ class App(QtCore.QObject): self.new_object("excellon", 'Combo_Excellon', initialize) + def on_edit_join_grb(self): + """ + Callback for Edit->Join Gerber. Joins the selected Gerber objects into + a new one. + + :return: None + """ + objs = self.collection.get_selected() + + for obj in objs: + if not isinstance(obj, FlatCAMGerber): + self.inform.emit("[error_notcl]Failed. Gerber joining works only on Gerber objects.") + return + + def initialize(obj, app): + FlatCAMGerber.merge(objs, obj) + + self.new_object("gerber", 'Combo_Gerber', initialize) + def on_convert_singlegeo_to_multigeo(self): obj = self.collection.get_active() diff --git a/FlatCAMGUI.py b/FlatCAMGUI.py index 016ebd9b..269dcdce 100644 --- a/FlatCAMGUI.py +++ b/FlatCAMGUI.py @@ -159,7 +159,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow): # Separator self.menuedit.addSeparator() self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), 'Edit Object\tE') - self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), '&Update Object\tCTRL+S') + self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), 'Save && Close Editor\tCTRL+S') # Separator self.menuedit.addSeparator() self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon('share/convert24.png'), 'Conversion') @@ -175,6 +175,10 @@ class FlatCAMGUI(QtWidgets.QMainWindow): QtGui.QIcon('share/join16.png'), 'Join Excellon(s) -> Excellon') self.menuedit_convertjoinexc.setToolTip( "Merge a selection of Excellon objects into a new combo Excellon object.") + self.menuedit_convertjoingrb = self.menuedit_convert.addAction( + QtGui.QIcon('share/join16.png'), 'Join Gerber(s) -> Gerber') + self.menuedit_convertjoingrb.setToolTip( + "Merge a selection of Gerber objects into a new combo Gerber object.") # Separator self.menuedit_convert.addSeparator() self.menuedit_convert_sg2mg = self.menuedit_convert.addAction( @@ -372,7 +376,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow): self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon") self.toolbargeo.addSeparator() self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor") - self.update_obj_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object") + self.update_obj_btn = self.toolbargeo.addAction( + QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor" + ) self.update_obj_btn.setEnabled(False) self.toolbargeo.addSeparator() self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete") diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 761f03a8..dbd1745c 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -366,6 +366,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber): if grb_final.solid_geometry is None: grb_final.solid_geometry = [] + if type(grb_final.solid_geometry) is not list: grb_final.solid_geometry = [grb_final.solid_geometry] @@ -380,10 +381,11 @@ class FlatCAMGerber(FlatCAMObj, Gerber): # Expand lists if type(grb) is list: FlatCAMGerber.merge(grb, grb_final) + else: # If not list, just append + for geos in grb.solid_geometry: + grb_final.solid_geometry.append(geos) - # If not list, just append - else: - grb_final.solid_geometry.append(grb.solid_geometry) + grb_final.solid_geometry = MultiPolygon(grb_final.solid_geometry) def __init__(self, name): Gerber.__init__(self, steps_per_circle=self.app.defaults["gerber_circle_steps"]) diff --git a/README.md b/README.md index 8ec6d495..6101db65 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing. ================================================= +28.01.2018 + +- fixed the FlatCAMGerber.merge() function +- added a new menu entry for the Gerber Join function: Edit -> Conversions -> "Join Gerber(s) to Gerber" allowing joining Gerber objects into a final Gerber object + + 27.01.2018 - added more key shortcuts into the application; they are now displayed in the GUI menu's @@ -20,7 +26,6 @@ CAD program, and create G-Code for Isolation routing. - modified grbl_laser postprocessor file so it includes a Sxxxx command on the line with M02 (laser active) whenever a value is enter in the Spindlespeed entry field - remade the EDIT -> PREFERENCES window, the Excellon and Gerber sections. Created a new section named TOOLS - 26.01.2019 - fixed grbl_11 postprocessor in linear_code() function diff --git a/camlib.py b/camlib.py index 9d65a705..ea9f2646 100644 --- a/camlib.py +++ b/camlib.py @@ -2965,7 +2965,7 @@ class Gerber (Geometry): return 0, 0, 0, 0 def bounds_rec(obj): - if type(obj) is list: + if type(obj) is list and type(obj) is not MultiPolygon: minx = Inf miny = Inf maxx = -Inf @@ -2980,7 +2980,12 @@ class Gerber (Geometry): maxx = max(maxx, maxx_) maxy = max(maxy, maxy_) else: - minx_, miny_, maxx_, maxy_ = bounds_rec(k) + try: + minx_, miny_, maxx_, maxy_ = bounds_rec(k) + except Exception as e: + log.debug("camlib.Geometry.bounds() --> %s" % str(e)) + return + minx = min(minx, minx_) miny = min(miny, miny_) maxx = max(maxx, maxx_)