- some changes related to the fact that the geometry default tool diameter value can be comma separated string of tool diameters

This commit is contained in:
Marius Stanciu 2019-12-24 00:54:45 +02:00 committed by Marius
parent 6df765cda1
commit 0e5e3a5227
5 changed files with 73 additions and 33 deletions

View File

@ -5831,51 +5831,64 @@ class App(QtCore.QObject):
self.defaults['geometry_toolchangexy'] = "%.*f, %.*f" % (self.decimals, coords_xy[0],
self.decimals, coords_xy[1])
elif dim == 'geometry_cnctooldia':
tools_diameters = []
try:
tools_string = self.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
if type(self.defaults["geometry_cnctooldia"]) == float:
tools_diameters = [self.defaults["geometry_cnctooldia"]]
else:
try:
tools_string = self.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
self.defaults['geometry_cnctooldia'] = ''
for t in range(len(tools_diameters)):
tools_diameters[t] *= sfactor
self.defaults['geometry_cnctooldia'] += "%.*f," % (self.decimals, tools_diameters[t])
elif dim == 'tools_ncctools':
ncctools = []
try:
tools_string = self.defaults["tools_ncctools"].split(",")
ncctools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
ncctools = list()
if type(self.defaults["tools_ncctools"]) == float:
ncctools = [self.defaults["tools_ncctools"]]
else:
try:
tools_string = self.defaults["tools_ncctools"].split(",")
ncctools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
self.defaults['tools_ncctools'] = ''
for t in range(len(ncctools)):
ncctools[t] *= sfactor
self.defaults['tools_ncctools'] += "%.*f," % (self.decimals, ncctools[t])
elif dim == 'tools_solderpaste_tools':
sptools = []
try:
tools_string = self.defaults["tools_solderpaste_tools"].split(",")
sptools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
sptools = list()
if type(self.defaults["tools_solderpaste_tools"]) == float:
sptools = [self.defaults["tools_solderpaste_tools"]]
else:
try:
tools_string = self.defaults["tools_solderpaste_tools"].split(",")
sptools = [eval(a) for a in tools_string if a != '']
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
self.defaults['tools_solderpaste_tools'] = ""
for t in range(len(sptools)):
sptools[t] *= sfactor
self.defaults['tools_solderpaste_tools'] += "%.*f," % (self.decimals, sptools[t])
elif dim == 'tools_solderpaste_xy_toolchange':
coordinates = self.defaults["tools_solderpaste_xy_toolchange"].split(",")
sp_coords = [float(eval(a)) for a in coordinates if a != '']
sp_coords[0] *= sfactor
sp_coords[1] *= sfactor
self.defaults['tools_solderpaste_xy_toolchange'] = "%.*f, %.*f" % (self.decimals, sp_coords[0],
self.decimals, sp_coords[1])
try:
coordinates = self.defaults["tools_solderpaste_xy_toolchange"].split(",")
sp_coords = [float(eval(a)) for a in coordinates if a != '']
sp_coords[0] *= sfactor
sp_coords[1] *= sfactor
self.defaults['tools_solderpaste_xy_toolchange'] = "%.*f, %.*f" % (self.decimals, sp_coords[0],
self.decimals, sp_coords[1])
except Exception as e:
log.debug("App.on_toggle_units().scale_options() --> %s" % str(e))
continue
elif dim == 'global_gridx' or dim == 'global_gridy':
if new_units == 'IN':
val = 0.1

View File

@ -1007,7 +1007,16 @@ class ToolsDB(QtWidgets.QWidget):
dict_elem = dict()
dict_elem['name'] = 'new_tool'
dict_elem['tooldia'] = self.app.defaults["geometry_cnctooldia"]
if type(self.app.defaults["geometry_cnctooldia"]) == float:
dict_elem['tooldia'] = self.app.defaults["geometry_cnctooldia"]
else:
try:
tools_string = self.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
dict_elem['tooldia'] = tools_diameters[0] if tools_diameters else 0.0
except Exception as e:
self.app.log.debug("ToolDB.build_db_ui.on_tool_add() --> %s" % str(e))
dict_elem['offset'] = 'Path'
dict_elem['offset_value'] = 0.0
dict_elem['type'] = 'Rough'

View File

@ -3588,7 +3588,15 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
})
if "cnctooldia" not in self.options:
self.options["cnctooldia"] = self.app.defaults["geometry_cnctooldia"]
if type(self.app.defaults["geometry_cnctooldia"]) == float:
self.options["cnctooldia"] = self.app.defaults["geometry_cnctooldia"]
else:
try:
tools_string = self.app.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
self.options["cnctooldia"] = tools_diameters[0] if tools_diameters else 0.0
except Exception as e:
log.debug("FlatCAMObj.FlatCAMGeometry.init() --> %s" % str(e))
self.options["startz"] = self.app.defaults["geometry_startz"]

View File

@ -15,13 +15,14 @@ CAD program, and create G-Code for Isolation routing.
- added a method to darken the outline color for Gerber objects when they have the color set
- when Printing as PDF Gerber objects now the rendered color is the print color
- speed up the plotting in OpenGL(3D) graphic mode
- spped up the color setting for Gerber object when using the OpenGL(3D) graphic mode
- speed up the color setting for Gerber object when using the OpenGL(3D) graphic mode
- setting color for Gerber objects work on a selection of Gerber objects
- ~~when the selection is changed in the Project Tree the selection shape on canvas is deleted~~
- if an object is selected on Project Tree and it does not have the selection shape drawn, first click on canvas over it will draw the selection shape
- in Tool Transform added a new feature named 'Buffer'. For Geometry and Gerber objects will create (and replace) a geometry at a distance from the original geometry and for Excellon will adjust the Tool diameters
- solved issue #355 - when the tool diameter field in the Edit → Preferences → Geometry → Geometry General → Tools → Tool dia is only one the app failed to read it
- solved issue #356 - in Tools DB can not be added more than one tool if a translation is active
- some changes related to the fact that the geometry default tool diameter value can be comma separated string of tool diameters
22.12.2019

View File

@ -3466,11 +3466,20 @@ class CNCjob(Geometry):
flat_geometry = self.flatten(temp_solid_geometry, pathonly=True)
log.debug("%d paths" % len(flat_geometry))
if type(self.app.defaults["geometry_cnctooldia"]) == float:
default_dia = self.app.defaults["geometry_cnctooldia"]
else:
try:
tools_string = self.defaults["geometry_cnctooldia"].split(",")
tools_diameters = [eval(a) for a in tools_string if a != '']
default_dia = tools_diameters[0] if tools_diameters else 0.0
except Exception as e:
self.app.log.debug("camlib.CNCJob.generate_from_geometry_2() --> %s" % str(e))
try:
self.tooldia = float(tooldia) if tooldia else self.app.defaults["geometry_cnctooldia"]
self.tooldia = float(tooldia) if tooldia else default_dia
except ValueError:
self.tooldia = [float(el) for el in tooldia.split(',') if el != ''] if tooldia is not None else \
self.app.defaults["geometry_cnctooldia"]
self.tooldia = [float(el) for el in tooldia.split(',') if el != ''] if tooldia is not None else default_dia
self.z_cut = float(z_cut) if z_cut is not None else self.app.defaults["geometry_cutz"]
self.z_move = float(z_move) if z_move is not None else self.app.defaults["geometry_travelz"]