- application wide change: introduced the precision parameters in Edit -> Preferences who will control how many decimals to use in the app parameters

This commit is contained in:
Marius Stanciu
2019-12-05 15:18:54 +02:00
parent 19b5f732b5
commit 0d0f872244
53 changed files with 481 additions and 445 deletions

View File

@@ -89,6 +89,17 @@ class TclCommandCopperClear(TclCommand):
name = args['name']
# Get source object.
try:
obj = self.app.collection.get_by_name(str(name))
except Exception as e:
log.debug("TclCommandCopperClear.execute() --> %s" % str(e))
self.raise_tcl_error("%s: %s" % (_("Could not retrieve object"), name))
return "Could not retrieve object: %s" % name
if obj is None:
return "Object not found: %s" % name
if 'tooldia' in args:
tooldia = str(args['tooldia'])
else:
@@ -181,7 +192,7 @@ class TclCommandCopperClear(TclCommand):
tooluid += 1
ncc_tools.update({
int(tooluid): {
'tooldia': float('%.4f' % tool),
'tooldia': float('%.*f' % (obj.decimals, tool)),
'offset': 'Path',
'offset_value': 0.0,
'type': 'Iso',
@@ -204,17 +215,6 @@ class TclCommandCopperClear(TclCommand):
else:
outname = name + "_ncc_rm"
# Get source object.
try:
obj = self.app.collection.get_by_name(str(name))
except Exception as e:
log.debug("TclCommandCopperClear.execute() --> %s" % str(e))
self.raise_tcl_error("%s: %s" % (_("Could not retrieve object"), name))
return "Could not retrieve object: %s" % name
if obj is None:
return "Object not found: %s" % name
# Non-Copper clear all polygons in the non-copper clear object
if 'all' in args and args['all'] == 1:
self.app.ncclear_tool.clear_copper(ncc_obj=obj,

View File

@@ -89,6 +89,13 @@ class TclCommandDrillcncjob(TclCommandSignaled):
name = args['name']
obj = self.app.collection.get_by_name(name)
if obj is None:
if muted == 0:
self.raise_tcl_error("Object not found: %s" % name)
else:
return "fail"
if 'outname' not in args:
args['outname'] = name + "_cnc"
@@ -97,13 +104,6 @@ class TclCommandDrillcncjob(TclCommandSignaled):
else:
muted = 0
obj = self.app.collection.get_by_name(name)
if obj is None:
if muted == 0:
self.raise_tcl_error("Object not found: %s" % name)
else:
return "fail"
if not isinstance(obj, FlatCAMExcellon):
if muted == 0:
self.raise_tcl_error('Expected FlatCAMExcellon, got %s %s.' % (name, type(obj)))
@@ -127,10 +127,8 @@ class TclCommandDrillcncjob(TclCommandSignaled):
req_tools = set()
for tool in obj.tools:
for req_dia in diameters:
obj_dia_form = float('%.2f' % float(obj.tools[tool]["C"])) if units == 'MM' else \
float('%.4f' % float(obj.tools[tool]["C"]))
req_dia_form = float('%.2f' % float(req_dia)) if units == 'MM' else \
float('%.4f' % float(req_dia))
obj_dia_form = float('%.*f' % (obj.decimals, float(obj.tools[tool]["C"])))
req_dia_form = float('%.*f' % (obj.decimals, float(req_dia)))
if 'diatol' in args:
tolerance = args['diatol'] / 100

View File

@@ -70,15 +70,15 @@ class TclCommandMillDrills(TclCommandSignaled):
name = args['name']
if 'outname' not in args:
args['outname'] = name + "_mill_drills"
try:
obj = self.app.collection.get_by_name(str(name))
except Exception as e:
obj = None
self.raise_tcl_error("Could not retrieve object: %s" % name)
if 'outname' not in args:
args['outname'] = name + "_mill_drills"
if not obj.drills:
self.raise_tcl_error("The Excellon object has no drills: %s" % name)
@@ -92,10 +92,8 @@ class TclCommandMillDrills(TclCommandSignaled):
req_tools = set()
for tool in obj.tools:
for req_dia in diameters:
obj_dia_form = float('%.2f' % float(obj.tools[tool]["C"])) if units == 'MM' else \
float('%.4f' % float(obj.tools[tool]["C"]))
req_dia_form = float('%.2f' % float(req_dia)) if units == 'MM' else \
float('%.4f' % float(req_dia))
obj_dia_form = float('%.*f' % (obj.decimals, float(obj.tools[tool]["C"])))
req_dia_form = float('%.*f' % (obj.decimals, float(req_dia)))
if 'diatol' in args:
tolerance = args['diatol'] / 100

View File

@@ -70,15 +70,15 @@ class TclCommandMillSlots(TclCommandSignaled):
name = args['name']
if 'outname' not in args:
args['outname'] = name + "_mill_slots"
try:
obj = self.app.collection.get_by_name(str(name))
except Exception:
obj = None
self.raise_tcl_error("Could not retrieve object: %s" % name)
if 'outname' not in args:
args['outname'] = name + "_mill_slots"
if not obj.slots:
self.raise_tcl_error("The Excellon object has no slots: %s" % name)
@@ -91,10 +91,8 @@ class TclCommandMillSlots(TclCommandSignaled):
req_tools = set()
for tool in obj.tools:
for req_dia in diameters:
obj_dia_form = float('%.2f' % float(obj.tools[tool]["C"])) if units == 'MM' else \
float('%.4f' % float(obj.tools[tool]["C"]))
req_dia_form = float('%.2f' % float(req_dia)) if units == 'MM' else \
float('%.4f' % float(req_dia))
obj_dia_form = float('%.*f' % (obj.decimals, float(obj.tools[tool]["C"])))
req_dia_form = float('%.*f' % (obj.decimals, float(req_dia)))
if 'diatol' in args:
tolerance = args['diatol'] / 100

View File

@@ -89,6 +89,14 @@ class TclCommandPaint(TclCommand):
name = args['name']
# Get source object.
try:
obj = self.app.collection.get_by_name(str(name))
except Exception as e:
log.debug("TclCommandPaint.execute() --> %s" % str(e))
self.raise_tcl_error("%s: %s" % (_("Could not retrieve object"), name))
return "Could not retrieve object: %s" % name
if 'tooldia' in args:
tooldia = str(args['tooldia'])
else:
@@ -129,14 +137,6 @@ class TclCommandPaint(TclCommand):
else:
outname = name + "_paint"
# Get source object.
try:
obj = self.app.collection.get_by_name(str(name))
except Exception as e:
log.debug("TclCommandPaint.execute() --> %s" % str(e))
self.raise_tcl_error("%s: %s" % (_("Could not retrieve object"), name))
return "Could not retrieve object: %s" % name
try:
tools = [float(eval(dia)) for dia in tooldia.split(",") if dia != '']
except AttributeError:
@@ -181,7 +181,7 @@ class TclCommandPaint(TclCommand):
tooluid += 1
paint_tools.update({
int(tooluid): {
'tooldia': float('%.4f' % tool),
'tooldia': float('%.*f' % (obj.decimals, tool)),
'offset': 'Path',
'offset_value': 0.0,
'type': 'Iso',