From 57f47622613b0c7a98413b817532a7b703e01d65 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 14 Sep 2019 18:27:08 +0300 Subject: [PATCH] - added to the NonCopperClear.clear_copper() a parameter to be able to run it non-threaded --- FlatCAMObj.py | 19 ++++++++++--------- README.md | 1 + flatcamTools/ToolNonCopperClear.py | 16 +++++++++++----- tclCommands/TclCommandCncjob.py | 6 ++++-- tclCommands/TclCommandCopperClear.py | 6 ++++-- 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 396eb42e..05d933ab 100644 --- a/FlatCAMObj.py +++ b/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 diff --git a/README.md b/README.md index 0f8eb364..5cd168f1 100644 --- a/README.md +++ b/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 diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index 413a022d..e79f73c2 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/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): # diff --git a/tclCommands/TclCommandCncjob.py b/tclCommands/TclCommandCncjob.py index c76fb3c9..bf56649e 100644 --- a/tclCommands/TclCommandCncjob.py +++ b/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') \ No newline at end of file diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 552ab393..38b0aa90 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/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"