Jelajahi Sumber

- added to the NonCopperClear.clear_copper() a parameter to be able to run it non-threaded

Marius Stanciu 6 tahun lalu
induk
melakukan
57f4762261

+ 10 - 9
FlatCAMObj.py

@@ -5150,15 +5150,16 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             # it seems that the tolerance needs to be a lot lower value than 0.01 and it was hardcoded initially
             # to a value of 0.0005 which is 20 times less than 0.01
             tol = float(self.app.defaults['global_tolerance']) / 20
-            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,
-                                             multidepth=multidepth, depthpercut=depthperpass,
-                                             toolchange=toolchange, toolchangez=toolchangez, toolchangexy=toolchangexy,
-                                             extracut=extracut, startz=startz, endz=endz,
-                                             pp_geometry_name=ppname_g
-                                             )
+            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,
+                multidepth=multidepth, depthpercut=depthperpass,
+                toolchange=toolchange, toolchangez=toolchangez, toolchangexy=toolchangexy,
+                extracut=extracut, startz=startz, endz=endz,
+                pp_geometry_name=ppname_g
+            )
 
             app_obj.progress.emit(50)
             # tell gcode_parse from which point to start drawing the lines depending on what kind of object is the

+ 1 - 0
README.md

@@ -22,6 +22,7 @@ CAD program, and create G-Code for Isolation routing.
 - whenever the user changes the Excellon format values for loading files, the Export Excellon Format values will be updated
 - made optional the behavior of Excellon Export values following the values in the Excellon Loading section
 - updated the translations (except RU) and the POT file
+- added to the NonCopperClear.clear_copper() a parameter to be able to run it non-threaded
 
 13.09.2019
 

+ 11 - 5
flatcamTools/ToolNonCopperClear.py

@@ -1291,7 +1291,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
                      order=None,
                      method=None,
                      rest=None,
-                     tools_storage=None):
+                     tools_storage=None,
+                     run_threaded=True):
         """
         Clear the excess copper from the entire object.
 
@@ -1312,6 +1313,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
         :param rest: True if to use rest-machining
         :param tools_storage: whether to use the current tools_storage self.ncc_tools or a different one.
         Usage of the different one is related to when this function is called from a TcL command.
+        :param run_threaded: If True the method will be run in a threaded way suitable for GUI usage; if False it will
+        run non-threaded for TclShell usage
         :return:
         """
 
@@ -2200,11 +2203,14 @@ class NonCopperClear(FlatCAMTool, Gerber):
             # focus on Selected Tab
             self.app.ui.notebook.setCurrentWidget(self.app.ui.selected_tab)
 
-        # Promise object with the new name
-        self.app.collection.promise(name)
+        if run_threaded:
+            # Promise object with the new name
+            self.app.collection.promise(name)
 
-        # Background
-        self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
+            # Background
+            self.app.worker_task.emit({'fcn': job_thread, 'params': [self.app]})
+        else:
+            job_thread(app_obj=self.app)
 
     # def on_ncc(self):
     #

+ 4 - 2
tclCommands/TclCommandCncjob.py

@@ -111,5 +111,7 @@ class TclCommandCncjob(TclCommandSignaled):
         # HACK !!! Should be solved elsewhere!!!
         # default option for multidepth is False
         obj.options['multidepth'] = False
-
-        obj.generatecncjob(use_thread=False, **args)
+        if not obj.multigeo:
+            obj.generatecncjob(use_thread=False, **args)
+        else:
+            self.raise_tcl_error('The object is a multi-geo geometry which is not supported in cncjob Tcl Command')

+ 4 - 2
tclCommands/TclCommandCopperClear.py

@@ -225,7 +225,8 @@ class TclCommandCopperClear(TclCommand):
                                                connect=connect,
                                                contour=contour,
                                                rest=rest,
-                                               tools_storage=ncc_tools)
+                                               tools_storage=ncc_tools,
+                                               run_threaded=False)
             return
 
         # Non-Copper clear all polygons found within the box object from the the non_copper cleared object
@@ -257,7 +258,8 @@ class TclCommandCopperClear(TclCommand):
                                                    connect=connect,
                                                    contour=contour,
                                                    rest=rest,
-                                                   tools_storage=ncc_tools)
+                                                   tools_storage=ncc_tools,
+                                                   run_threaded=False)
             return
         else:
             self.raise_tcl_error("%s:" % _("None of the following args: 'ref', 'all' were found or none was set to 1.\n"