From 02793f7ae297e2ef5acf8c7f7a35abaca65dcad8 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 12 Feb 2019 16:55:43 +0200 Subject: [PATCH] - starting to work on storing the solid_geometry for each tool in part in Excellon Object --- FlatCAMApp.py | 11 ++++++++--- FlatCAMObj.py | 43 +++++++++++++++++++++++++++++++------------ README.md | 1 + camlib.py | 10 ++++++++-- 4 files changed, 48 insertions(+), 17 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 9f770020..be5f6ced 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -6012,9 +6012,14 @@ class App(QtCore.QObject): log.debug("Could not create geometry for Excellon object.") return "fail" - if excellon_obj.is_empty(): - app_obj.inform.emit("[ERROR_NOTCL] No geometry found in file: " + filename) - return "fail" + # if excellon_obj.is_empty(): + # app_obj.inform.emit("[ERROR_NOTCL] No geometry found in file: " + filename) + # return "fail" + for tool in excellon_obj.tools: + if excellon_obj.tools[tool]['solid_geometry']: + return + app_obj.inform.emit("[ERROR_NOTCL] No geometry found in file: " + filename) + return "fail" with self.proc_container.new("Opening Excellon."): diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 86302331..306f78ea 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -1882,27 +1882,45 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): if not FlatCAMObj.plot(self): return - 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) + for tool in self.tools: + for geo in self.tools[tool]['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']) + for tool in self.tools: + for geo in self.tools[tool]['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: + # _ = 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?) # if self.options["solid"]: @@ -4118,6 +4136,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.plot_cb.setChecked(True) self.ui_connect() + class FlatCAMCNCjob(FlatCAMObj, CNCjob): """ Represents G-Code. diff --git a/README.md b/README.md index dec61081..374f770f 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing. - added a new parameter named Offset in the Excellon tool table - work in progress - finished work on Offset parameter in Excellon Object (Excellon Editor, camlib, FlatCAMObj updated to take this param in consideration) - fixed a bug where in Excellon editor when editing a file, a tool was automatically added. That is supposed to happen only for empty newly created Excellon Objects. +- starting to work on storing the solid_geometry for each tool in part in Excellon Object 10.02.2019 diff --git a/camlib.py b/camlib.py index f90359af..d9e968db 100644 --- a/camlib.py +++ b/camlib.py @@ -3510,6 +3510,7 @@ class Excellon(Geometry): spec = {"C": float(match.group(2))} self.tools[str(name_tool)] = spec log.debug(" Tool definition: %s %s" % (name_tool, spec)) + spec['solid_geometry'] = [] continue else: log.warning("Line ignored, it's a comment: %s" % eline) @@ -3569,6 +3570,7 @@ class Excellon(Geometry): spec = { "C": float(match.group(2)), } + spec['solid_geometry'] = [] self.tools[name] = spec log.debug(" Tool definition out of header: %s %s" % (name, spec)) @@ -3914,6 +3916,7 @@ class Excellon(Geometry): # "H": float(match.group(6)), # "Z": float(match.group(7)) } + spec['solid_geometry'] = [] self.tools[name] = spec log.debug(" Tool definition: %s %s" % (name, spec)) continue @@ -4082,7 +4085,8 @@ class Excellon(Geometry): continue tooldia = self.tools[drill['tool']]['C'] poly = drill['point'].buffer(tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4)) - self.solid_geometry.append(poly) + # self.solid_geometry.append(poly) + self.tools[drill['tool']]['solid_geometry'].append(poly) for slot in self.slots: slot_tooldia = self.tools[slot['tool']]['C'] @@ -4091,7 +4095,9 @@ class Excellon(Geometry): lines_string = LineString([start, stop]) poly = lines_string.buffer(slot_tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4)) - self.solid_geometry.append(poly) + # self.solid_geometry.append(poly) + self.tools[drill['tool']]['solid_geometry'].append(poly) + except Exception as e: log.debug("Excellon geometry creation failed due of ERROR: %s" % str(e)) return "fail"