- changed the Excellon defaults for zeros suppression to TZ (assumed that most Excellon without units in header will come out of older Eagle) and the Excellon export default is now with coordinates in decimal

This commit is contained in:
Marius Stanciu 2020-06-07 17:06:23 +03:00 committed by Marius
parent a4179d58a4
commit 5ce7011123
3 changed files with 36 additions and 7 deletions

View File

@ -12,6 +12,8 @@ CHANGELOG for FlatCAM beta
- refactoring in camlib.py. Made sure that some conditions are met, if some of the parameters are None then return failure. Modifications in generate_from_geometry_2 and generate_from_multitool_geometry methods
- fixed issue with trying to access GUI from different threads by adding a new signal for printing to shell messages
- fixed a small issue in Gerber file opener filter that did not see the *.TOP extension or *.outline extension
- in Excellon parser added a way to "guestimate" the units if no units are detected in the header. I may need to make it optional in Preferences
- changed the Excellon defaults for zeros suppression to TZ (assumed that most Excellon without units in header will come out of older Eagle) and the Excellon export default is now with coordinates in decimal
6.06.2020

View File

@ -115,12 +115,12 @@ class Excellon(Geometry):
# ## IN|MM -> Units are inherited from Geometry
self.units = self.app.defaults['units']
self.units_found = self.app.defaults['units']
# Trailing "T" or leading "L" (default)
# self.zeros = "T"
self.zeros = zeros or self.defaults["zeros"]
self.zeros_found = deepcopy(self.zeros)
self.units_found = deepcopy(self.units)
# this will serve as a default if the Excellon file has no info regarding of tool diameters (this info may be
# in another file like for PCB WIzard ECAD software
@ -134,6 +134,8 @@ class Excellon(Geometry):
self.excellon_format_upper_mm = excellon_format_upper_mm or self.defaults["excellon_format_upper_mm"]
self.excellon_format_lower_mm = excellon_format_lower_mm or self.defaults["excellon_format_lower_mm"]
self.excellon_units = excellon_units or self.defaults["excellon_units"]
self.excellon_units_found = None
# detected Excellon format is stored here:
self.excellon_format = None
@ -362,7 +364,7 @@ class Excellon(Geometry):
self.excellon_format_upper_in = match.group(1)
self.excellon_format_lower_in = match.group(2)
log.warning("Altium Excellon format preset found in comments: %s:%s" %
log.warning("Excellon format preset found in comments: %s:%s" %
(match.group(1), match.group(2)))
continue
else:
@ -384,6 +386,25 @@ class Excellon(Geometry):
if allegro_warning is True:
name_tool = 0
log.warning("Found end of the header: %s" % eline)
'''
In case that the units were not found in the header, we have two choices:
- one is to use the default value in the App Preferences
- the other is to make an evaluation based on a threshold
we process here the self.tools list and make a list with tools with diameter less or equal
with 0.1 and a list with tools with value greater than 0.1, 0.1 being the threshold value.
Most tools in Excellon are greater than 0.1mm therefore if most of the tools are under this
value it is safe to assume that the units are in INCH
'''
greater_tools = set()
lower_tools = set()
if not self.excellon_units_found and self.tools:
for tool in self.tools:
tool_dia = float(self.tools[tool]['C'])
lower_tools.add(tool_dia) if tool_dia <= 0.1 else greater_tools.add(tool_dia)
assumed_units = "IN" if len(lower_tools) > len(greater_tools) else "MM"
self.units = assumed_units
continue
# ## Alternative units format M71/M72
@ -802,6 +823,8 @@ class Excellon(Geometry):
match = self.units_re.match(eline)
if match:
self.units = {"METRIC": "MM", "INCH": "IN"}[match.group(1)]
self.excellon_units_found = self.units
self.zeros = match.group(2) # "T" or "L". Might be empty
self.excellon_format = match.group(3)
if self.excellon_format:
@ -815,9 +838,9 @@ class Excellon(Geometry):
self.excellon_format_lower_in = lower
# Modified for issue #80
log.warning("UNITS found inline before conversion: %s" % self.units)
log.warning("UNITS found inline - Value before conversion: %s" % self.units)
self.convert_units(self.units)
log.warning("UNITS found inline after conversion: %s" % self.units)
log.warning("UNITS found inline - Value after conversion: %s" % self.units)
if self.units == 'MM':
log.warning("Excellon format preset is: %s:%s" %
(str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm)))
@ -836,6 +859,7 @@ class Excellon(Geometry):
log.warning("Type of UNITS found inline, in header, after conversion: %s" % self.units)
log.warning("Excellon format preset is: %s:%s" %
(str(self.excellon_format_upper_in), str(self.excellon_format_lower_in)))
self.excellon_units_found = "IN"
continue
elif "METRIC" in eline:
line_units = "MM"
@ -845,6 +869,7 @@ class Excellon(Geometry):
log.warning("Type of UNITS found inline, in header, after conversion: %s" % self.units)
log.warning("Excellon format preset is: %s:%s" %
(str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm)))
self.excellon_units_found = "MM"
continue
# Search for zeros type again because it might be alone on the line
@ -857,7 +882,9 @@ class Excellon(Geometry):
# ## Units and number format outside header# ##
match = self.units_re.match(eline)
if match:
self.units = self.units = {"METRIC": "MM", "INCH": "IN"}[match.group(1)]
self.units = {"METRIC": "MM", "INCH": "IN"}[match.group(1)]
self.excellon_units_found = self.units
self.zeros = match.group(2) # "T" or "L". Might be empty
self.excellon_format = match.group(3)
if self.excellon_format:

View File

@ -227,7 +227,7 @@ class FlatCAMDefaults:
"excellon_format_lower_in": 4,
"excellon_format_upper_mm": 3,
"excellon_format_lower_mm": 3,
"excellon_zeros": "L",
"excellon_zeros": "T",
"excellon_units": "INCH",
"excellon_update": True,
@ -282,7 +282,7 @@ class FlatCAMDefaults:
# Excellon Export
"excellon_exp_units": 'INCH',
"excellon_exp_format": 'ndec',
"excellon_exp_format": 'dec',
"excellon_exp_integer": 2,
"excellon_exp_decimals": 4,
"excellon_exp_zeros": 'LZ',