- fixed bug in Tool Subtract that did not allow subtracting Gerber objects
This commit is contained in:
parent
50abe2883d
commit
4c1fdd2e2d
@ -7,7 +7,7 @@
|
||||
# ########################################################## ##
|
||||
|
||||
from PyQt5 import QtCore
|
||||
# import traceback
|
||||
import traceback
|
||||
|
||||
|
||||
class Worker(QtCore.QObject):
|
||||
@ -61,7 +61,7 @@ class Worker(QtCore.QObject):
|
||||
task['fcn'](*task['params'])
|
||||
except Exception as e:
|
||||
self.app.thread_exception.emit(e)
|
||||
# print(traceback.format_exc())
|
||||
print(traceback.format_exc())
|
||||
# raise e
|
||||
finally:
|
||||
self.task_completed.emit(self.name)
|
||||
|
@ -13,6 +13,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||
|
||||
- removed the f-strings replacing them with the traditional string formatting due of not being supported by older versions of Python 3
|
||||
- fixed some TclCommands: MillDrills and OpenGerber
|
||||
- fixed bug in Tool Subtract that did not allow subtracting Gerber objects
|
||||
|
||||
18.11.2019
|
||||
|
||||
|
@ -248,23 +248,22 @@ class ToolSub(FlatCAMTool):
|
||||
|
||||
self.target_grb_obj_name = self.target_gerber_combo.currentText()
|
||||
if self.target_grb_obj_name == '':
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("No Target object loaded."))
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("No Target object loaded."))
|
||||
return
|
||||
|
||||
self.app.inform.emit('%s' % _("Loading geometry from Gerber objects."))
|
||||
|
||||
# Get target object.
|
||||
try:
|
||||
self.target_grb_obj = self.app.collection.get_by_name(self.target_grb_obj_name)
|
||||
except Exception as e:
|
||||
log.debug("ToolSub.on_grb_intersection_click() --> %s" % str(e))
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' %
|
||||
(_("Could not retrieve object"), self.obj_name))
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name))
|
||||
return "Could not retrieve object: %s" % self.target_grb_obj_name
|
||||
|
||||
self.sub_grb_obj_name = self.sub_gerber_combo.currentText()
|
||||
if self.sub_grb_obj_name == '':
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' %
|
||||
_("No Subtractor object loaded."))
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s' % _("No Subtractor object loaded."))
|
||||
return
|
||||
|
||||
# Get substractor object.
|
||||
@ -272,20 +271,19 @@ class ToolSub(FlatCAMTool):
|
||||
self.sub_grb_obj = self.app.collection.get_by_name(self.sub_grb_obj_name)
|
||||
except Exception as e:
|
||||
log.debug("ToolSub.on_grb_intersection_click() --> %s" % str(e))
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' %
|
||||
(_("Could not retrieve object"), self.obj_name))
|
||||
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve object"), self.obj_name))
|
||||
return "Could not retrieve object: %s" % self.sub_grb_obj_name
|
||||
|
||||
# crate the new_apertures dict structure
|
||||
for apid in self.target_grb_obj.apertures:
|
||||
self.new_apertures[apid] = {}
|
||||
self.new_apertures[apid] = dict()
|
||||
self.new_apertures[apid]['type'] = 'C'
|
||||
self.new_apertures[apid]['size'] = self.target_grb_obj.apertures[apid]['size']
|
||||
self.new_apertures[apid]['geometry'] = []
|
||||
self.new_apertures[apid]['geometry'] = list()
|
||||
|
||||
geo_solid_union_list = []
|
||||
geo_follow_union_list = []
|
||||
geo_clear_union_list = []
|
||||
geo_solid_union_list = list()
|
||||
geo_follow_union_list = list()
|
||||
geo_clear_union_list = list()
|
||||
|
||||
for apid1 in self.sub_grb_obj.apertures:
|
||||
if 'geometry' in self.sub_grb_obj.apertures[apid1]:
|
||||
@ -297,6 +295,7 @@ class ToolSub(FlatCAMTool):
|
||||
if 'clear' in elem:
|
||||
geo_clear_union_list.append(elem['clear'])
|
||||
|
||||
self.app.inform.emit('%s' % _("Processing geometry from Subtractor Gerber object."))
|
||||
self.sub_solid_union = cascaded_union(geo_solid_union_list)
|
||||
self.sub_follow_union = cascaded_union(geo_follow_union_list)
|
||||
self.sub_clear_union = cascaded_union(geo_clear_union_list)
|
||||
@ -310,15 +309,15 @@ class ToolSub(FlatCAMTool):
|
||||
|
||||
for apid in self.target_grb_obj.apertures:
|
||||
geo = self.target_grb_obj.apertures[apid]['geometry']
|
||||
self.app.worker_task.emit({'fcn': self.aperture_intersection,
|
||||
'params': [apid, geo]})
|
||||
self.app.worker_task.emit({'fcn': self.aperture_intersection, 'params': [apid, geo]})
|
||||
|
||||
def aperture_intersection(self, apid, geo):
|
||||
new_geometry = []
|
||||
new_geometry = list()
|
||||
|
||||
log.debug("Working on promise: %s" % str(apid))
|
||||
|
||||
with self.app.proc_container.new('%s: %s...' % (_("Parsing geometry for aperture", str(apid)))):
|
||||
with self.app.proc_container.new('%s: %s...' % (_("Parsing geometry for aperture"), str(apid))):
|
||||
|
||||
for geo_el in geo:
|
||||
new_el = dict()
|
||||
|
||||
@ -378,6 +377,8 @@ class ToolSub(FlatCAMTool):
|
||||
|
||||
new_geometry.append(deepcopy(new_el))
|
||||
|
||||
self.app.inform.emit('%s: %s...' % (_("Finished parsing geometry for aperture"), str(apid)))
|
||||
|
||||
if new_geometry:
|
||||
while not self.new_apertures[apid]['geometry']:
|
||||
self.new_apertures[apid]['geometry'] = deepcopy(new_geometry)
|
||||
@ -412,6 +413,7 @@ class ToolSub(FlatCAMTool):
|
||||
poly_buff = work_poly_buff.buffer(0.0000001)
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
try:
|
||||
poly_buff = poly_buff.buffer(-0.0000001)
|
||||
except ValueError:
|
||||
|
Loading…
Reference in New Issue
Block a user