Browse Source

- fixed bug in ToolCutout where creating a cutout object geometry from another external isolation geometry failed
- fixed bug in cncjob TclCommand where the gcode could not be correctly generated due of missing bounds params in obj.options dict
- fixed a hardcoded tolerance in FlatCAMGeometry.generatecncjob() and in FlatCAMGeometry.mtool_gen_cncjob() to use the parameter from Preferences

Marius Stanciu 6 năm trước cách đây
mục cha
commit
a5ffe475dd
5 tập tin đã thay đổi với 39 bổ sung10 xóa
  1. 11 5
      FlatCAMObj.py
  2. 6 0
      README.md
  3. 1 4
      camlib.py
  4. 7 1
      flatcamTools/ToolCutOut.py
  5. 14 0
      tclCommands/TclCommandGeoCutout.py

+ 11 - 5
FlatCAMObj.py

@@ -4448,8 +4448,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
 
                 app_obj.progress.emit(40)
 
+                tol = float(self.app.defaults['global_tolerance'])
                 res = job_obj.generate_from_geometry_2(
-                    self, tooldia=tooldia_val, offset=tool_offset, tolerance=0.0005,
+                    self, tooldia=tooldia_val, offset=tool_offset, tolerance=tol,
                     z_cut=z_cut, z_move=z_move,
                     feedrate=feedrate, feedrate_z=feedrate_z, feedrate_rapid=feedrate_rapid,
                     spindlespeed=spindlespeed, spindledir=spindledir, dwell=dwell, dwelltime=dwelltime,
@@ -4681,9 +4682,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 spindledir = self.app.defaults['geometry_spindledir']
 
                 tool_solid_geometry = self.tools[current_uid]['solid_geometry']
+                tol = float(self.app.defaults['global_tolerance'])
                 res = job_obj.generate_from_multitool_geometry(
                     tool_solid_geometry, tooldia=tooldia_val, offset=tool_offset,
-                    tolerance=0.0005, z_cut=z_cut, z_move=z_move,
+                    tolerance=tol, z_cut=z_cut, z_move=z_move,
                     feedrate=feedrate, feedrate_z=feedrate_z, feedrate_rapid=feedrate_rapid,
                     spindlespeed=spindlespeed, spindledir=spindledir, dwell=dwell, dwelltime=dwelltime,
                     multidepth=multidepth, depthpercut=depthpercut,
@@ -4740,7 +4742,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             else:
                 self.app.new_object("cncjob", outname, job_init_multi_geometry)
 
-
     def generatecncjob(self, outname=None,
                        tooldia=None, offset=None,
                        z_cut=None, z_move=None,
@@ -4849,8 +4850,13 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                             'or self.options["feedrate_probe"]'
                         ))
 
-            # TODO: The tolerance should not be hard coded. Just for testing.
-            job_obj.generate_from_geometry_2(self, tooldia=tooldia, offset=offset, tolerance=0.0005,
+            job_obj.options['xmin'] = self.options['xmin']
+            job_obj.options['ymin'] = self.options['ymin']
+            job_obj.options['xmax'] = self.options['xmax']
+            job_obj.options['ymax'] = self.options['ymax']
+
+            tol = float(self.app.defaults['global_tolerance'])
+            job_obj.generate_from_geometry_2(self, tooldia=tooldia, offset=offset, tolerance=tol,
                                              z_cut=z_cut, z_move=z_move,
                                              feedrate=feedrate, feedrate_z=feedrate_z, feedrate_rapid=feedrate_rapid,
                                              spindlespeed=spindlespeed, dwell=dwell, dwelltime=dwelltime,

+ 6 - 0
README.md

@@ -9,6 +9,12 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+7.06.2019
+
+- fixed bug in ToolCutout where creating a cutout object geometry from another external isolation geometry failed
+- fixed bug in cncjob TclCommand where the gcode could not be correctly generated due of missing bounds params in obj.options dict
+- fixed a hardcoded tolerance in FlatCAMGeometry.generatecncjob() and in FlatCAMGeometry.mtool_gen_cncjob() to use the parameter from Preferences
+
 5.06.2019
 
 - updated translations

+ 1 - 4
camlib.py

@@ -4969,7 +4969,6 @@ class CNCjob(Geometry):
 
         self.pp_solderpaste_name = None
 
-
         # Controls if the move from Z_Toolchange to Z_Move is done fast with G0 or normally with G1
         self.f_plunge = None
 
@@ -5817,7 +5816,7 @@ class CNCjob(Geometry):
         if offset != 0.0:
             offset_for_use = offset
 
-            if offset <0:
+            if offset < 0:
                 a, b, c, d = bounds_rec(geometry.solid_geometry)
                 # if the offset is less than half of the total length or less than half of the total width of the
                 # solid geometry it's obvious we can't do the offset
@@ -5929,8 +5928,6 @@ class CNCjob(Geometry):
             if shape is not None:  # TODO: This shouldn't have happened.
                 storage.insert(shape)
 
-        # self.input_geometry_bounds = geometry.bounds()
-
         if not append:
             self.gcode = ""
 

+ 7 - 1
flatcamTools/ToolCutOut.py

@@ -424,7 +424,8 @@ class CutOut(FlatCAMTool):
                     geo = (geo.buffer(margin + abs(dia / 2))).exterior
 
                 # Get min and max data for each object as we just cut rectangles across X or Y
-                xmin, ymin, xmax, ymax = geo.bounds
+                xmin, ymin, xmax, ymax = recursive_bounds(geo)
+
                 px = 0.5 * (xmin + xmax) + margin
                 py = 0.5 * (ymin + ymax) + margin
                 lenx = (xmax - xmin) + (margin * 2)
@@ -475,6 +476,11 @@ class CutOut(FlatCAMTool):
                     solid_geo.append(geo)
 
             geo_obj.solid_geometry = deepcopy(solid_geo)
+            xmin, ymin, xmax, ymax = recursive_bounds(geo_obj.solid_geometry)
+            geo_obj.options['xmin'] = xmin
+            geo_obj.options['ymin'] = ymin
+            geo_obj.options['xmax'] = xmax
+            geo_obj.options['ymax'] = ymax
 
         outname = cutout_obj.options["name"] + "_cutout"
         self.app.new_object('geometry', outname, geo_init)

+ 14 - 0
tclCommands/TclCommandGeoCutout.py

@@ -165,6 +165,11 @@ class TclCommandGeoCutout(TclCommandSignaled):
 
         # Get min and max data for each object as we just cut rectangles across X or Y
         xmin, ymin, xmax, ymax = cutout_obj.bounds()
+        cutout_obj.options['xmin'] = xmin
+        cutout_obj.options['ymin'] = ymin
+        cutout_obj.options['xmax'] = xmax
+        cutout_obj.options['ymax'] = ymax
+
         px = 0.5 * (xmin + xmax) + margin
         py = 0.5 * (ymin + ymax) + margin
         lenghtx = (xmax - xmin) + (margin * 2)
@@ -260,6 +265,11 @@ class TclCommandGeoCutout(TclCommandSignaled):
                                                   px + gapsize,
                                                   ymax + gapsize)
                 geo_obj.solid_geometry = deepcopy(geo)
+                geo_obj.options['xmin'] = cutout_obj.options['xmin']
+                geo_obj.options['ymin'] = cutout_obj.options['ymin']
+                geo_obj.options['xmax'] = cutout_obj.options['xmax']
+                geo_obj.options['ymax'] = cutout_obj.options['ymax']
+
                 app_obj.disable_plots(objects=[cutout_obj])
 
                 app_obj.inform.emit("[success] Any-form Cutout operation finished.")
@@ -317,6 +327,10 @@ class TclCommandGeoCutout(TclCommandSignaled):
                                                   px + gapsize,
                                                   ymax + gapsize)
                 geo_obj.solid_geometry = deepcopy(geo)
+                geo_obj.options['xmin'] = cutout_obj.options['xmin']
+                geo_obj.options['ymin'] = cutout_obj.options['ymin']
+                geo_obj.options['xmax'] = cutout_obj.options['xmax']
+                geo_obj.options['ymax'] = cutout_obj.options['ymax']
                 app_obj.inform.emit("[success] Any-form Cutout operation finished.")
 
             outname = cutout_obj.options["name"] + "_cutout"