- some fixes in Drilling Tool and in camlib.py file

This commit is contained in:
Marius Stanciu
2021-01-27 02:16:05 +02:00
committed by Marius
parent 575e29fcaa
commit f7021d89de
3 changed files with 30 additions and 24 deletions

View File

@@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta
================================================= =================================================
27.01.2021
- some fixes in Drilling Tool and in camlib.py file
21.01.2021 21.01.2021
- added ability to see the verbose log when importing SVG's (if set in preferences) - added ability to see the verbose log when importing SVG's (if set in preferences)

View File

@@ -306,19 +306,25 @@ class ToolDrilling(AppTool, Excellon):
except Exception: except Exception:
pass pass
try:
loaded_obj = self.app.collection.get_by_name(self.ui.object_combo.get_value())
except Exception as err:
self.app.log.error("ToolDrilling -> Loaded Excellon object error. %s" % str(err))
return
# reset the Excellon preprocessor combo # reset the Excellon preprocessor combo
self.ui.pp_excellon_name_cb.clear() self.ui.pp_excellon_name_cb.clear()
# populate Excellon preprocessor combobox list # populate Excellon preprocessor combobox list
pp_list = [] if loaded_obj.options['tools_drill_ppname_e'] == 'Check_points':
for name in self.app.preprocessors.keys(): pp_list = ['Check_points']
# the HPGL preprocessor or Paste_ are not for Excellon job therefore don't add it else:
if name in ['hpgl', 'Paste_1']: pp_list = []
continue for name in self.app.preprocessors.keys():
elif name == 'Check_points': # the HPGL preprocessor or Paste_ are not for Excellon job therefore don't add it
pp_list = [name] if name in ['hpgl', 'Paste_1']:
break continue
pp_list.append(name) pp_list.append(name)
pp_list.sort() pp_list.sort()
if 'default' in pp_list: if 'default' in pp_list:
pp_list.remove('default') pp_list.remove('default')
pp_list.insert(0, 'default') pp_list.insert(0, 'default')
@@ -330,12 +336,6 @@ class ToolDrilling(AppTool, Excellon):
self.ui.order_radio.set_value(self.app.defaults["tools_drill_tool_order"]) self.ui.order_radio.set_value(self.app.defaults["tools_drill_tool_order"])
try:
loaded_obj = self.app.collection.get_by_name(self.ui.object_combo.get_value())
except Exception as err:
self.app.log.error("ToolDrilling -> Loaded Excellon object error. %s" % str(err))
return
if loaded_obj: if loaded_obj:
outname = loaded_obj.options['name'] outname = loaded_obj.options['name']
else: else:

View File

@@ -612,7 +612,7 @@ class Geometry(object):
self.options['xmax'] = xmax self.options['xmax'] = xmax
self.options['ymax'] = ymax self.options['ymax'] = ymax
except Exception as e: except Exception as e:
log.error("Failed. The object has no bounds properties. %s" % str(e)) self.app.log.error("Failed. The object has no bounds properties. %s" % str(e))
def add_polygon(self, points, tool=None): def add_polygon(self, points, tool=None):
""" """
@@ -653,7 +653,7 @@ class Geometry(object):
self.options['xmax'] = xmax self.options['xmax'] = xmax
self.options['ymax'] = ymax self.options['ymax'] = ymax
except Exception as e: except Exception as e:
log.error("Failed. The object has no bounds properties. %s" % str(e)) self.app.log.error("Failed. The object has no bounds properties. %s" % str(e))
def add_polyline(self, points, tool=None): def add_polyline(self, points, tool=None):
""" """
@@ -677,7 +677,7 @@ class Geometry(object):
try: try:
self.solid_geometry = self.solid_geometry.union(new_line) self.solid_geometry = self.solid_geometry.union(new_line)
except Exception as e: except Exception as e:
log.error("Failed to run union on polylines. %s" % str(e)) self.app.log.error("Failed to run union on polylines. %s" % str(e))
return "fail" return "fail"
# add in tools solid_geometry # add in tools solid_geometry
@@ -694,7 +694,7 @@ class Geometry(object):
self.options['xmax'] = xmax self.options['xmax'] = xmax
self.options['ymax'] = ymax self.options['ymax'] = ymax
except Exception as e: except Exception as e:
log.error("Failed. The object has no bounds properties. %s" % str(e)) self.app.log.error("Failed. The object has no bounds properties. %s" % str(e))
def is_empty(self): def is_empty(self):
if isinstance(self.solid_geometry, BaseGeometry) or isinstance(self.solid_geometry, Polygon) or \ if isinstance(self.solid_geometry, BaseGeometry) or isinstance(self.solid_geometry, Polygon) or \
@@ -732,7 +732,7 @@ class Geometry(object):
if isinstance(target, LineString) or isinstance(target, LineString) or isinstance(target, MultiLineString): if isinstance(target, LineString) or isinstance(target, LineString) or isinstance(target, MultiLineString):
diffs.append(target.difference(toolgeo)) diffs.append(target.difference(toolgeo))
else: else:
log.warning("Not implemented.") self.app.log.warning("Not implemented.")
self.solid_geometry = unary_union(diffs) self.solid_geometry = unary_union(diffs)
@@ -746,10 +746,10 @@ class Geometry(object):
# fixed issue of getting bounds only for one level lists of objects # fixed issue of getting bounds only for one level lists of objects
# now it can get bounds for nested lists of objects # now it can get bounds for nested lists of objects
log.debug("camlib.Geometry.bounds()") self.app.log.debug("camlib.Geometry.bounds()")
if self.solid_geometry is None: if self.solid_geometry is None:
log.debug("solid_geometry is None") self.app.log.debug("solid_geometry is None")
return 0, 0, 0, 0 return 0, 0, 0, 0
def bounds_rec(obj): def bounds_rec(obj):
@@ -7558,7 +7558,7 @@ class CNCjob(Geometry):
:rtype: tuple :rtype: tuple
""" """
log.debug("camlib.CNCJob.bounds()") self.app.log.debug("camlib.CNCJob.bounds()")
def bounds_rec(obj): def bounds_rec(obj):
if type(obj) is list: if type(obj) is list:
@@ -7606,6 +7606,8 @@ class CNCjob(Geometry):
maxy = -np.Inf maxy = -np.Inf
try: try:
for geo in v['solid_geometry']: for geo in v['solid_geometry']:
if isinstance(geo, list):
geo = unary_union(geo)
if geo.is_empty: if geo.is_empty:
continue continue
minx_, miny_, maxx_, maxy_ = bounds_rec(geo) minx_, miny_, maxx_, maxy_ = bounds_rec(geo)