|
@@ -90,7 +90,6 @@ class Excellon(Geometry):
|
|
|
self.tools = {}
|
|
self.tools = {}
|
|
|
# list to store the drills, see above for description
|
|
# list to store the drills, see above for description
|
|
|
self.drills = []
|
|
self.drills = []
|
|
|
-
|
|
|
|
|
# self.slots (list) to store the slots; each is a dictionary
|
|
# self.slots (list) to store the slots; each is a dictionary
|
|
|
self.slots = []
|
|
self.slots = []
|
|
|
|
|
|
|
@@ -107,7 +106,7 @@ class Excellon(Geometry):
|
|
|
self.index_per_tool = {} # Dictionary to store the indexed points for each tool
|
|
self.index_per_tool = {} # Dictionary to store the indexed points for each tool
|
|
|
|
|
|
|
|
# ## IN|MM -> Units are inherited from Geometry
|
|
# ## IN|MM -> Units are inherited from Geometry
|
|
|
- # self.units = units
|
|
|
|
|
|
|
+ self.units = self.app.defaults['units']
|
|
|
|
|
|
|
|
# Trailing "T" or leading "L" (default)
|
|
# Trailing "T" or leading "L" (default)
|
|
|
# self.zeros = "T"
|
|
# self.zeros = "T"
|
|
@@ -305,8 +304,7 @@ class Excellon(Geometry):
|
|
|
# and we need to exit from here
|
|
# and we need to exit from here
|
|
|
if self.detect_gcode_re.search(eline):
|
|
if self.detect_gcode_re.search(eline):
|
|
|
log.warning("This is GCODE mark: %s" % eline)
|
|
log.warning("This is GCODE mark: %s" % eline)
|
|
|
- self.app.inform.emit('[ERROR_NOTCL] %s: %s' %
|
|
|
|
|
- (_('This is GCODE mark'), eline))
|
|
|
|
|
|
|
+ self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_('This is GCODE mark'), eline))
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
# Header Begin (M48) #
|
|
# Header Begin (M48) #
|
|
@@ -341,11 +339,11 @@ class Excellon(Geometry):
|
|
|
if line_units == 'MILS':
|
|
if line_units == 'MILS':
|
|
|
spec = {"C": (float(match.group(2)) / 1000)}
|
|
spec = {"C": (float(match.group(2)) / 1000)}
|
|
|
self.tools[str(name_tool)] = spec
|
|
self.tools[str(name_tool)] = spec
|
|
|
- log.debug(" Tool definition: %s %s" % (name_tool, spec))
|
|
|
|
|
|
|
+ log.debug("Tool definition: %s %s" % (name_tool, spec))
|
|
|
else:
|
|
else:
|
|
|
spec = {"C": float(match.group(2))}
|
|
spec = {"C": float(match.group(2))}
|
|
|
self.tools[str(name_tool)] = spec
|
|
self.tools[str(name_tool)] = spec
|
|
|
- log.debug(" Tool definition: %s %s" % (name_tool, spec))
|
|
|
|
|
|
|
+ log.debug("Tool definition: %s %s" % (name_tool, spec))
|
|
|
spec['solid_geometry'] = []
|
|
spec['solid_geometry'] = []
|
|
|
continue
|
|
continue
|
|
|
# search for Altium Excellon Format / Sprint Layout who is included as a comment
|
|
# search for Altium Excellon Format / Sprint Layout who is included as a comment
|
|
@@ -387,17 +385,18 @@ class Excellon(Geometry):
|
|
|
# object's units.
|
|
# object's units.
|
|
|
match = self.meas_re.match(eline)
|
|
match = self.meas_re.match(eline)
|
|
|
if match:
|
|
if match:
|
|
|
- # self.units = {"1": "MM", "2": "IN"}[match.group(1)]
|
|
|
|
|
|
|
+ self.units = {"1": "MM", "2": "IN"}[match.group(1)]
|
|
|
|
|
|
|
|
# Modified for issue #80
|
|
# Modified for issue #80
|
|
|
- self.convert_units({"1": "MM", "2": "IN"}[match.group(1)])
|
|
|
|
|
- log.debug(" Units: %s" % self.units)
|
|
|
|
|
|
|
+ log.debug("ALternative M71/M72 units found, before conversion: %s" % self.units)
|
|
|
|
|
+ self.convert_units(self.units)
|
|
|
|
|
+ log.debug("ALternative M71/M72 units found, after conversion: %s" % self.units)
|
|
|
if self.units == 'MM':
|
|
if self.units == 'MM':
|
|
|
- log.warning("Excellon format preset is: %s" % self.excellon_format_upper_mm + \
|
|
|
|
|
- ':' + str(self.excellon_format_lower_mm))
|
|
|
|
|
|
|
+ log.warning("Excellon format preset is: %s:%s" %
|
|
|
|
|
+ (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm)))
|
|
|
else:
|
|
else:
|
|
|
- log.warning("Excellon format preset is: %s" % self.excellon_format_upper_in + \
|
|
|
|
|
- ':' + str(self.excellon_format_lower_in))
|
|
|
|
|
|
|
+ log.warning("Excellon format preset is: %s:%s" %
|
|
|
|
|
+ (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in)))
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
# ### Body ####
|
|
# ### Body ####
|
|
@@ -784,13 +783,13 @@ class Excellon(Geometry):
|
|
|
# ## Units and number format # ##
|
|
# ## Units and number format # ##
|
|
|
match = self.units_re.match(eline)
|
|
match = self.units_re.match(eline)
|
|
|
if match:
|
|
if match:
|
|
|
- self.units = match.group(1)
|
|
|
|
|
|
|
+ self.units = self.units = {"METRIC": "MM", "INCH": "IN"}[match.group(1)]
|
|
|
self.zeros = match.group(2) # "T" or "L". Might be empty
|
|
self.zeros = match.group(2) # "T" or "L". Might be empty
|
|
|
self.excellon_format = match.group(3)
|
|
self.excellon_format = match.group(3)
|
|
|
if self.excellon_format:
|
|
if self.excellon_format:
|
|
|
upper = len(self.excellon_format.partition('.')[0])
|
|
upper = len(self.excellon_format.partition('.')[0])
|
|
|
lower = len(self.excellon_format.partition('.')[2])
|
|
lower = len(self.excellon_format.partition('.')[2])
|
|
|
- if self.units == 'METRIC':
|
|
|
|
|
|
|
+ if self.units == 'MM':
|
|
|
self.excellon_format_upper_mm = upper
|
|
self.excellon_format_upper_mm = upper
|
|
|
self.excellon_format_lower_mm = lower
|
|
self.excellon_format_lower_mm = lower
|
|
|
else:
|
|
else:
|
|
@@ -798,57 +797,55 @@ class Excellon(Geometry):
|
|
|
self.excellon_format_lower_in = lower
|
|
self.excellon_format_lower_in = lower
|
|
|
|
|
|
|
|
# Modified for issue #80
|
|
# Modified for issue #80
|
|
|
- self.convert_units({"INCH": "IN", "METRIC": "MM"}[self.units])
|
|
|
|
|
- # log.warning(" Units/Format: %s %s" % (self.units, self.zeros))
|
|
|
|
|
- log.warning("Units: %s" % self.units)
|
|
|
|
|
|
|
+ log.warning("UNITS found inline before conversion: %s" % self.units)
|
|
|
|
|
+ self.convert_units(self.units)
|
|
|
|
|
+ log.warning("UNITS found inline after conversion: %s" % self.units)
|
|
|
if self.units == 'MM':
|
|
if self.units == 'MM':
|
|
|
- log.warning("Excellon format preset is: %s" % str(self.excellon_format_upper_mm) +
|
|
|
|
|
- ':' + str(self.excellon_format_lower_mm))
|
|
|
|
|
|
|
+ log.warning("Excellon format preset is: %s:%s" %
|
|
|
|
|
+ (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm)))
|
|
|
else:
|
|
else:
|
|
|
- log.warning("Excellon format preset is: %s" % str(self.excellon_format_upper_in) +
|
|
|
|
|
- ':' + str(self.excellon_format_lower_in))
|
|
|
|
|
- log.warning("Type of zeros found inline: %s" % self.zeros)
|
|
|
|
|
|
|
+ log.warning("Excellon format preset is: %s:%s" %
|
|
|
|
|
+ (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in)))
|
|
|
|
|
+ log.warning("Type of ZEROS found inline, in header: %s" % self.zeros)
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
# Search for units type again it might be alone on the line
|
|
# Search for units type again it might be alone on the line
|
|
|
if "INCH" in eline:
|
|
if "INCH" in eline:
|
|
|
- line_units = "INCH"
|
|
|
|
|
|
|
+ line_units = "IN"
|
|
|
# Modified for issue #80
|
|
# Modified for issue #80
|
|
|
- self.convert_units({"INCH": "IN", "METRIC": "MM"}[line_units])
|
|
|
|
|
- log.warning("Type of UNITS found inline: %s" % line_units)
|
|
|
|
|
- log.warning("Excellon format preset is: %s" % str(self.excellon_format_upper_in) +
|
|
|
|
|
- ':' + str(self.excellon_format_lower_in))
|
|
|
|
|
- # TODO: not working
|
|
|
|
|
- # FlatCAMApp.App.inform.emit("Detected INLINE: %s" % str(eline))
|
|
|
|
|
|
|
+ log.warning("Type of UNITS found inline, in header, before conversion: %s" % line_units)
|
|
|
|
|
+ self.convert_units(line_units)
|
|
|
|
|
+ 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)))
|
|
|
continue
|
|
continue
|
|
|
elif "METRIC" in eline:
|
|
elif "METRIC" in eline:
|
|
|
- line_units = "METRIC"
|
|
|
|
|
|
|
+ line_units = "MM"
|
|
|
# Modified for issue #80
|
|
# Modified for issue #80
|
|
|
- self.convert_units({"INCH": "IN", "METRIC": "MM"}[line_units])
|
|
|
|
|
- log.warning("Type of UNITS found inline: %s" % line_units)
|
|
|
|
|
- log.warning("Excellon format preset is: %s" % str(self.excellon_format_upper_mm) +
|
|
|
|
|
- ':' + str(self.excellon_format_lower_mm))
|
|
|
|
|
- # TODO: not working
|
|
|
|
|
- # FlatCAMApp.App.inform.emit("Detected INLINE: %s" % str(eline))
|
|
|
|
|
|
|
+ log.warning("Type of UNITS found inline, in header, before conversion: %s" % line_units)
|
|
|
|
|
+ self.convert_units(line_units)
|
|
|
|
|
+ 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)))
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
# Search for zeros type again because it might be alone on the line
|
|
# Search for zeros type again because it might be alone on the line
|
|
|
match = re.search(r'[LT]Z', eline)
|
|
match = re.search(r'[LT]Z', eline)
|
|
|
if match:
|
|
if match:
|
|
|
self.zeros = match.group()
|
|
self.zeros = match.group()
|
|
|
- log.warning("Type of zeros found: %s" % self.zeros)
|
|
|
|
|
|
|
+ log.warning("Type of ZEROS found: %s" % self.zeros)
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
# ## Units and number format outside header# ##
|
|
# ## Units and number format outside header# ##
|
|
|
match = self.units_re.match(eline)
|
|
match = self.units_re.match(eline)
|
|
|
if match:
|
|
if match:
|
|
|
- self.units = match.group(1)
|
|
|
|
|
|
|
+ self.units = self.units = {"METRIC": "MM", "INCH": "IN"}[match.group(1)]
|
|
|
self.zeros = match.group(2) # "T" or "L". Might be empty
|
|
self.zeros = match.group(2) # "T" or "L". Might be empty
|
|
|
self.excellon_format = match.group(3)
|
|
self.excellon_format = match.group(3)
|
|
|
if self.excellon_format:
|
|
if self.excellon_format:
|
|
|
upper = len(self.excellon_format.partition('.')[0])
|
|
upper = len(self.excellon_format.partition('.')[0])
|
|
|
lower = len(self.excellon_format.partition('.')[2])
|
|
lower = len(self.excellon_format.partition('.')[2])
|
|
|
- if self.units == 'METRIC':
|
|
|
|
|
|
|
+ if self.units == 'MM':
|
|
|
self.excellon_format_upper_mm = upper
|
|
self.excellon_format_upper_mm = upper
|
|
|
self.excellon_format_lower_mm = lower
|
|
self.excellon_format_lower_mm = lower
|
|
|
else:
|
|
else:
|
|
@@ -856,18 +853,17 @@ class Excellon(Geometry):
|
|
|
self.excellon_format_lower_in = lower
|
|
self.excellon_format_lower_in = lower
|
|
|
|
|
|
|
|
# Modified for issue #80
|
|
# Modified for issue #80
|
|
|
- self.convert_units({"INCH": "IN", "METRIC": "MM"}[self.units])
|
|
|
|
|
- # log.warning(" Units/Format: %s %s" % (self.units, self.zeros))
|
|
|
|
|
- log.warning("Units: %s" % self.units)
|
|
|
|
|
|
|
+ log.warning("Type of UNITS found outside header, inline before conversion: %s" % self.units)
|
|
|
|
|
+ self.convert_units(self.units)
|
|
|
|
|
+ log.warning("Type of UNITS found outside header, inline after conversion: %s" % self.units)
|
|
|
|
|
+
|
|
|
if self.units == 'MM':
|
|
if self.units == 'MM':
|
|
|
- log.warning("Excellon format preset is: %s" % str(self.excellon_format_upper_mm) +
|
|
|
|
|
- ':' + str(self.excellon_format_lower_mm))
|
|
|
|
|
|
|
+ log.warning("Excellon format preset is: %s:%s" %
|
|
|
|
|
+ (str(self.excellon_format_upper_mm), str(self.excellon_format_lower_mm)))
|
|
|
else:
|
|
else:
|
|
|
- log.warning("Excellon format preset is: %s" % str(self.excellon_format_upper_in) +
|
|
|
|
|
- ':' + str(self.excellon_format_lower_in))
|
|
|
|
|
- log.warning("Type of zeros found outside header, inline: %s" % self.zeros)
|
|
|
|
|
-
|
|
|
|
|
- log.warning("UNITS found outside header")
|
|
|
|
|
|
|
+ log.warning("Excellon format preset is: %s:%s" %
|
|
|
|
|
+ (str(self.excellon_format_upper_in), str(self.excellon_format_lower_in)))
|
|
|
|
|
+ log.warning("Type of ZEROS found outside header, inline: %s" % self.zeros)
|
|
|
continue
|
|
continue
|
|
|
|
|
|
|
|
log.warning("Line ignored: %s" % eline)
|
|
log.warning("Line ignored: %s" % eline)
|
|
@@ -875,6 +871,7 @@ class Excellon(Geometry):
|
|
|
# make sure that since we are in headerless mode, we convert the tools only after the file parsing
|
|
# make sure that since we are in headerless mode, we convert the tools only after the file parsing
|
|
|
# is finished since the tools definitions are spread in the Excellon body. We use as units the value
|
|
# is finished since the tools definitions are spread in the Excellon body. We use as units the value
|
|
|
# from self.defaults['excellon_units']
|
|
# from self.defaults['excellon_units']
|
|
|
|
|
+
|
|
|
log.info("Zeros: %s, Units %s." % (self.zeros, self.units))
|
|
log.info("Zeros: %s, Units %s." % (self.zeros, self.units))
|
|
|
except Exception:
|
|
except Exception:
|
|
|
log.error("Excellon PARSING FAILED. Line %d: %s" % (line_num, eline))
|
|
log.error("Excellon PARSING FAILED. Line %d: %s" % (line_num, eline))
|
|
@@ -950,6 +947,8 @@ class Excellon(Geometry):
|
|
|
|
|
|
|
|
:return: None
|
|
:return: None
|
|
|
"""
|
|
"""
|
|
|
|
|
+
|
|
|
|
|
+ log.debug("flatcamParsers.ParseExcellon.Excellon.create_geometry()")
|
|
|
self.solid_geometry = []
|
|
self.solid_geometry = []
|
|
|
try:
|
|
try:
|
|
|
# clear the solid_geometry in self.tools
|
|
# clear the solid_geometry in self.tools
|
|
@@ -1084,16 +1083,29 @@ class Excellon(Geometry):
|
|
|
:type str: IN or MM
|
|
:type str: IN or MM
|
|
|
:return:
|
|
:return:
|
|
|
"""
|
|
"""
|
|
|
- log.debug("camlib.Excellon.convert_units()")
|
|
|
|
|
|
|
|
|
|
- factor = Geometry.convert_units(self, units)
|
|
|
|
|
|
|
+ # factor = Geometry.convert_units(self, units)
|
|
|
|
|
+ obj_units = units
|
|
|
|
|
+ if obj_units.upper() == self.units.upper():
|
|
|
|
|
+ factor = 1.0
|
|
|
|
|
+ elif obj_units.upper() == "MM":
|
|
|
|
|
+ factor = 25.4
|
|
|
|
|
+ elif obj_units.upper() == "IN":
|
|
|
|
|
+ factor = 1 / 25.4
|
|
|
|
|
+ else:
|
|
|
|
|
+ log.error("Unsupported units: %s" % str(obj_units))
|
|
|
|
|
+ factor = 1.0
|
|
|
|
|
+ log.debug("flatcamParsers.ParseExcellon.Excellon.convert_units() --> Factor: %s" % str(factor))
|
|
|
|
|
+
|
|
|
|
|
+ self.units = obj_units
|
|
|
|
|
+ self.scale(factor, factor)
|
|
|
|
|
+ self.file_units_factor = factor
|
|
|
|
|
|
|
|
# Tools
|
|
# Tools
|
|
|
for tname in self.tools:
|
|
for tname in self.tools:
|
|
|
self.tools[tname]["C"] *= factor
|
|
self.tools[tname]["C"] *= factor
|
|
|
|
|
|
|
|
self.create_geometry()
|
|
self.create_geometry()
|
|
|
-
|
|
|
|
|
return factor
|
|
return factor
|
|
|
|
|
|
|
|
def scale(self, xfactor, yfactor=None, point=None):
|
|
def scale(self, xfactor, yfactor=None, point=None):
|
|
@@ -1108,7 +1120,7 @@ class Excellon(Geometry):
|
|
|
:return: None
|
|
:return: None
|
|
|
:rtype: NOne
|
|
:rtype: NOne
|
|
|
"""
|
|
"""
|
|
|
- log.debug("camlib.Excellon.scale()")
|
|
|
|
|
|
|
+ log.debug("flatcamParsers.ParseExcellon.Excellon..scale()")
|
|
|
|
|
|
|
|
if yfactor is None:
|
|
if yfactor is None:
|
|
|
yfactor = xfactor
|
|
yfactor = xfactor
|