Ver Fonte

- fixed the Circle Steps parameter for both Gerber and Geometry objects not being applied and instead the app internal defaults were used.
- fixed the Tcl command Geocutout issue that gave an error when using the 4 or 8 value for gaps parameter

Marius Stanciu há 6 anos atrás
pai
commit
a545658d44
4 ficheiros alterados com 57 adições e 61 exclusões
  1. 2 2
      FlatCAMApp.py
  2. 4 0
      README.md
  3. 16 20
      camlib.py
  4. 35 39
      tclCommands/TclCommandGeoCutout.py

+ 2 - 2
FlatCAMApp.py

@@ -684,7 +684,7 @@ class App(QtCore.QObject):
             "gerber_noncopperrounded": False,
             "gerber_bboxmargin": 0.1,
             "gerber_bboxrounded": False,
-            "gerber_circle_steps": 64,
+            "gerber_circle_steps": 128,
             "gerber_use_buffer_for_union": True,
 
             # Gerber Advanced Options
@@ -746,7 +746,7 @@ class App(QtCore.QObject):
 
             # Geometry General
             "geometry_plot": True,
-            "geometry_circle_steps": 64,
+            "geometry_circle_steps": 128,
             "geometry_cnctooldia": 0.016,
 
             # Geometry Options

+ 4 - 0
README.md

@@ -8,6 +8,10 @@ Among other things, it can take a Gerber file generated by your favorite PCB
 CAD program, and create G-Code for Isolation routing.
 
 =================================================
+19.05.2019
+
+- fixed the Circle Steps parameter for both Gerber and Geometry objects not being applied and instead the app internal defaults were used.
+- fixed the Tcl command Geocutout issue that gave an error when using the 4 or 8 value for gaps parameter
 
 18.05.2019
 

+ 16 - 20
camlib.py

@@ -86,7 +86,7 @@ class Geometry(object):
 
     defaults = {
         "units": 'in',
-        "geo_steps_per_circle": 64
+        "geo_steps_per_circle": 128
     }
 
     def __init__(self, geo_steps_per_circle=None):
@@ -1884,10 +1884,10 @@ class Gerber (Geometry):
 
     """
 
-    defaults = {
-        "steps_per_circle": 56,
-        "use_buffer_for_union": True
-    }
+    # defaults = {
+    #     "steps_per_circle": 128,
+    #     "use_buffer_for_union": True
+    # }
 
     def __init__(self, steps_per_circle=None):
         """
@@ -1899,12 +1899,12 @@ class Gerber (Geometry):
         """
 
         # How to discretize a circle.
-        if steps_per_circle is None:
-            steps_per_circle = int(Gerber.defaults['steps_per_circle'])
-        self.steps_per_circle = int(steps_per_circle)
+        # if steps_per_circle is None:
+        #     steps_per_circle = int(Gerber.defaults['steps_per_circle'])
+        self.steps_per_circle = int(self.app.defaults["gerber_circle_steps"])
 
         # Initialize parent
-        Geometry.__init__(self, geo_steps_per_circle=int(steps_per_circle))
+        Geometry.__init__(self, geo_steps_per_circle=int(self.app.defaults["gerber_circle_steps"]))
 
         # Number format
         self.int_digits = 3
@@ -2043,7 +2043,7 @@ class Gerber (Geometry):
         self.am1_re = re.compile(r'^%AM([^\*]+)\*([^%]+)?(%)?$')
         self.am2_re = re.compile(r'(.*)%$')
 
-        self.use_buffer_for_union = self.defaults["use_buffer_for_union"]
+        self.use_buffer_for_union = self.app.defaults["gerber_use_buffer_for_union"]
 
     def aperture_parse(self, apertureId, apertureType, apParameters):
         """
@@ -2455,9 +2455,9 @@ class Gerber (Geometry):
                             log.debug("Bare op-code %d." % current_operation_code)
 
                             geo_dict = dict()
-                            flash = Gerber.create_flash_geometry(
+                            flash = self.create_flash_geometry(
                                 Point(current_x, current_y), self.apertures[current_aperture],
-                                int(self.steps_per_circle))
+                                self.steps_per_circle)
 
                             geo_dict['follow'] = Point([current_x, current_y])
 
@@ -2870,10 +2870,10 @@ class Gerber (Geometry):
                         geo_dict['follow'] = geo_flash
 
                         # this treats the case when we are storing geometry as solids
-                        flash = Gerber.create_flash_geometry(
+                        flash = self.create_flash_geometry(
                             Point( [linear_x, linear_y]),
                             self.apertures[current_aperture],
-                            int(self.steps_per_circle)
+                            self.steps_per_circle
                         )
                         if not flash.is_empty:
                             poly_buffer.append(flash)
@@ -3011,7 +3011,7 @@ class Gerber (Geometry):
 
                         this_arc = arc(center, radius, start, stop,
                                        arcdir[current_interpolation_mode],
-                                       int(self.steps_per_circle))
+                                       self.steps_per_circle)
 
                         # The last point in the computed arc can have
                         # numerical errors. The exact final point is the
@@ -3065,7 +3065,7 @@ class Gerber (Geometry):
                                 log.debug("########## ACCEPTING ARC ############")
                                 this_arc = arc(center, radius, start, stop,
                                                arcdir[current_interpolation_mode],
-                                               int(self.steps_per_circle))
+                                               self.steps_per_circle)
 
                                 # Replace with exact values
                                 this_arc[-1] = (circular_x, circular_y)
@@ -3132,7 +3132,6 @@ class Gerber (Geometry):
 
             conversion_factor = 25.4 if file_units == 'IN' else (1/25.4) if file_units != app_units else 1
 
-
             # --- Apply buffer ---
             # this treats the case when we are storing geometry as paths
             self.follow_geometry = follow_buffer
@@ -3175,9 +3174,6 @@ class Gerber (Geometry):
 
         # log.debug('Flashing @%s, Aperture: %s' % (location, aperture))
 
-        if steps_per_circle is None:
-            steps_per_circle = 64
-
         if type(location) == list:
             location = Point(location)
 

+ 35 - 39
tclCommands/TclCommandGeoCutout.py

@@ -2,6 +2,7 @@ from ObjectCollection import *
 from tclCommands.TclCommand import TclCommandSignaled
 from copy import deepcopy
 
+
 class TclCommandGeoCutout(TclCommandSignaled):
     """
         Tcl shell command to create a board cutout geometry. Allow cutout for any shape. Cuts holding gaps from geometry.
@@ -65,7 +66,6 @@ class TclCommandGeoCutout(TclCommandSignaled):
         :return:
         """
 
-
         def subtract_rectangle(obj_, x0, y0, x1, y1):
             pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
             obj_.subtract_polygon(pts)
@@ -73,7 +73,6 @@ class TclCommandGeoCutout(TclCommandSignaled):
         def substract_rectangle_geo(geo, x0, y0, x1, y1):
             pts = [(x0, y0), (x1, y0), (x1, y1), (x0, y1)]
 
-
             def flatten(geometry=None, reset=True, pathonly=False):
                 """
                 Creates a list of non-iterable linear geometry objects.
@@ -89,15 +88,15 @@ class TclCommandGeoCutout(TclCommandSignaled):
                 if reset:
                     self.flat_geometry = []
 
-                ## If iterable, expand recursively.
+                # If iterable, expand recursively.
                 try:
-                    for geo in geometry:
-                        if geo is not None:
-                            flatten(geometry=geo,
+                    for geo_el in geometry:
+                        if geo_el is not None:
+                            flatten(geometry=geo_el,
                                     reset=False,
                                     pathonly=pathonly)
 
-                ## Not iterable, do the actual indexing and add.
+                # Not iterable, do the actual indexing and add.
                 except TypeError:
                     if pathonly and type(geometry) == Polygon:
                         self.flat_geometry.append(geometry.exterior)
@@ -151,14 +150,15 @@ class TclCommandGeoCutout(TclCommandSignaled):
         # Get source object.
         try:
             cutout_obj = self.app.collection.get_by_name(str(name))
-        except:
+        except Exception as e:
+            log.debug("TclCommandGeoCutout --> %s" % str(e))
             return "Could not retrieve object: %s" % name
 
         if 0 in {dia}:
             self.app.inform.emit("[WARNING]Tool Diameter is zero value. Change it to a positive real number.")
             return "Tool Diameter is zero value. Change it to a positive real number."
 
-        if gaps not in ['lr', 'tb', '2lr', '2tb', 4, 8]:
+        if gaps not in ['lr', 'tb', '2lr', '2tb', '4', '8']:
             self.app.inform.emit("[WARNING]Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. "
                                  "Fill in a correct value and retry. ")
             return
@@ -226,47 +226,47 @@ class TclCommandGeoCutout(TclCommandSignaled):
             def geo_init(geo_obj, app_obj):
                 try:
                     geo = cutout_obj.isolation_geometry((dia / 2), iso_type=0, corner=2, follow=None)
-                except Exception as e:
-                    log.debug("TclCommandGeoCutout.execute() --> %s" % str(e))
+                except Exception as exc:
+                    log.debug("TclCommandGeoCutout.execute() --> %s" % str(exc))
                     return 'fail'
 
                 if gaps_u == 8 or gaps_u == '2lr':
                     geo = substract_rectangle_geo(geo,
-                                       xmin - gapsize,  # botleft_x
-                                       py - gapsize + lenghty / 4,  # botleft_y
-                                       xmax + gapsize,  # topright_x
-                                       py + gapsize + lenghty / 4)  # topright_y
+                                                  xmin - gapsize,  # botleft_x
+                                                  py - gapsize + lenghty / 4,  # botleft_y
+                                                  xmax + gapsize,  # topright_x
+                                                  py + gapsize + lenghty / 4)  # topright_y
                     geo = substract_rectangle_geo(geo,
-                                       xmin - gapsize,
-                                       py - gapsize - lenghty / 4,
-                                       xmax + gapsize,
-                                       py + gapsize - lenghty / 4)
+                                                  xmin - gapsize,
+                                                  py - gapsize - lenghty / 4,
+                                                  xmax + gapsize,
+                                                  py + gapsize - lenghty / 4)
 
                 if gaps_u == 8 or gaps_u == '2tb':
                     geo = substract_rectangle_geo(geo,
-                                       px - gapsize + lenghtx / 4,
-                                       ymin - gapsize,
-                                       px + gapsize + lenghtx / 4,
-                                       ymax + gapsize)
+                                                  px - gapsize + lenghtx / 4,
+                                                  ymin - gapsize,
+                                                  px + gapsize + lenghtx / 4,
+                                                  ymax + gapsize)
                     geo = substract_rectangle_geo(geo,
-                                       px - gapsize - lenghtx / 4,
-                                       ymin - gapsize,
-                                       px + gapsize - lenghtx / 4,
-                                       ymax + gapsize)
+                                                  px - gapsize - lenghtx / 4,
+                                                  ymin - gapsize,
+                                                  px + gapsize - lenghtx / 4,
+                                                  ymax + gapsize)
 
                 if gaps_u == 4 or gaps_u == 'lr':
                     geo = substract_rectangle_geo(geo,
-                                       xmin - gapsize,
-                                       py - gapsize,
-                                       xmax + gapsize,
-                                       py + gapsize)
+                                                  xmin - gapsize,
+                                                  py - gapsize,
+                                                  xmax + gapsize,
+                                                  py + gapsize)
 
                 if gaps_u == 4 or gaps_u == 'tb':
                     geo = substract_rectangle_geo(geo,
-                                       px - gapsize,
-                                       ymin - gapsize,
-                                       px + gapsize,
-                                       ymax + gapsize)
+                                                  px - gapsize,
+                                                  ymin - gapsize,
+                                                  px + gapsize,
+                                                  ymax + gapsize)
                 geo_obj.solid_geometry = geo
 
             outname = cutout_obj.options["name"] + "_cutout"
@@ -276,7 +276,3 @@ class TclCommandGeoCutout(TclCommandSignaled):
         else:
             self.app.inform.emit("[ERROR]Cancelled. Object type is not supported.")
             return
-
-
-
-