diff --git a/README.md b/README.md index 88581323..15b0da2e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ CAD program, and create G-Code for Isolation routing. - modified the calling of the editor2object() slot function to fix an issue with updating geometry imported from SVG file, after edit - working on Gerber Editor - added the key shortcuts: wip - made saving of the project file non-blocking and also while saving the project file, if the user tries again to close the app while project file is being saved, the app will close only after saving is complete (the project file size is non zero) -- fixed the quit action when denying the save, to save the default values and the QSettings +- fixed the camlib.Geometry.import_svg() and camlib.Gerber.bounds() to work when importing SVG files as Gerber 31.03.2019 diff --git a/camlib.py b/camlib.py index 8ffb8179..0d3eef78 100644 --- a/camlib.py +++ b/camlib.py @@ -621,7 +621,6 @@ class Geometry(object): # flatten the self.solid_geometry list for import_svg() to import SVG as Gerber self.solid_geometry = list(self.flatten_list(self.solid_geometry)) - #self.solid_geometry = cascaded_union(self.solid_geometry) geos_text = getsvgtext(svg_root, object_type, units=units) if geos_text is not None: @@ -632,7 +631,8 @@ class Geometry(object): _, minimy, _, maximy = i.bounds h2 = (maximy - minimy) * 0.5 geos_text_f.append(translate(scale(i, 1.0, -1.0, origin=(0, 0)), yoff=(h + h2))) - self.solid_geometry = [self.solid_geometry, geos_text_f] + if geos_text_f: + self.solid_geometry = self.solid_geometry + geos_text_f def import_dxf(self, filename, object_type=None, units='MM'): """ @@ -3246,16 +3246,17 @@ class Gerber (Geometry): maxx = max(maxx, maxx_) maxy = max(maxy, maxy_) else: - try: - minx_, miny_, maxx_, maxy_ = bounds_rec(k) - except Exception as e: - log.debug("camlib.Geometry.bounds() --> %s" % str(e)) - return + if not k.is_empty: + try: + minx_, miny_, maxx_, maxy_ = bounds_rec(k) + except Exception as e: + log.debug("camlib.Gerber.bounds() --> %s" % str(e)) + return - minx = min(minx, minx_) - miny = min(miny, miny_) - maxx = max(maxx, maxx_) - maxy = max(maxy, maxy_) + minx = min(minx, minx_) + miny = min(miny, miny_) + maxx = max(maxx, maxx_) + maxy = max(maxy, maxy_) return minx, miny, maxx, maxy else: # it's a Shapely object, return it's bounds