- fixed the Repeated code parsing in Excellon Parse
This commit is contained in:
parent
280eb1dc3a
commit
376c8058d9
|
@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
|
|
||||||
=================================================
|
=================================================
|
||||||
|
|
||||||
|
4.04.2020
|
||||||
|
|
||||||
|
- fixed the Repeated code parsing in Excellon Parse
|
||||||
|
|
||||||
1.04.2020
|
1.04.2020
|
||||||
|
|
||||||
- updated the SVG parser to take into consideration the 'Close' svg element and paths that are made from a single line (we may need to switch to svgpathtools module)
|
- updated the SVG parser to take into consideration the 'Close' svg element and paths that are made from a single line (we may need to switch to svgpathtools module)
|
||||||
|
|
|
@ -618,82 +618,92 @@ class Excellon(Geometry):
|
||||||
match = self.coordsnoperiod_re.search(eline)
|
match = self.coordsnoperiod_re.search(eline)
|
||||||
if match:
|
if match:
|
||||||
matchr = self.repeat_re.search(eline)
|
matchr = self.repeat_re.search(eline)
|
||||||
if matchr:
|
if matchr: # if we have a repeat command
|
||||||
repeat = int(matchr.group(1))
|
repeat = int(matchr.group(1))
|
||||||
|
|
||||||
try:
|
if match.group(1):
|
||||||
x = self.parse_number(match.group(1))
|
repeating_x = self.parse_number(match.group(1))
|
||||||
repeating_x = current_x
|
else:
|
||||||
current_x = x
|
repeating_x = 0
|
||||||
except TypeError:
|
|
||||||
x = current_x
|
|
||||||
repeating_x = 0
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
|
|
||||||
try:
|
if match.group(2):
|
||||||
y = self.parse_number(match.group(2))
|
repeating_y = self.parse_number(match.group(2))
|
||||||
repeating_y = current_y
|
else:
|
||||||
current_y = y
|
repeating_y = 0
|
||||||
except TypeError:
|
|
||||||
y = current_y
|
|
||||||
repeating_y = 0
|
|
||||||
except Exception:
|
|
||||||
return
|
|
||||||
|
|
||||||
if x is None or y is None:
|
coordx = current_x
|
||||||
log.error("Missing coordinates")
|
coordy = current_y
|
||||||
|
|
||||||
|
while repeat > 0:
|
||||||
|
if repeating_x:
|
||||||
|
coordx += repeating_x
|
||||||
|
if repeating_y:
|
||||||
|
coordy += repeating_y
|
||||||
|
self.drills.append({'point': Point((coordx, coordy)), 'tool': current_tool})
|
||||||
|
|
||||||
|
repeat -= 1
|
||||||
|
current_x = coordx
|
||||||
|
current_y = coordy
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# ## Excellon Routing parse
|
else: # those are normal coordinates
|
||||||
if len(re.findall("G00", eline)) > 0:
|
try:
|
||||||
self.match_routing_start = 'G00'
|
x = self.parse_number(match.group(1))
|
||||||
|
current_x = x
|
||||||
|
except TypeError:
|
||||||
|
x = current_x
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
|
||||||
# signal that there are milling slots operations
|
try:
|
||||||
self.defaults['excellon_drills'] = False
|
y = self.parse_number(match.group(2))
|
||||||
|
current_y = y
|
||||||
|
except TypeError:
|
||||||
|
y = current_y
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
|
||||||
self.routing_flag = 0
|
if x is None or y is None:
|
||||||
slot_start_x = x
|
log.error("Missing coordinates")
|
||||||
slot_start_y = y
|
continue
|
||||||
continue
|
|
||||||
|
|
||||||
if self.routing_flag == 0:
|
# ## Excellon Routing parse
|
||||||
if len(re.findall("G01", eline)) > 0:
|
if len(re.findall("G00", eline)) > 0:
|
||||||
self.match_routing_stop = 'G01'
|
self.match_routing_start = 'G00'
|
||||||
|
|
||||||
# signal that there are milling slots operations
|
# signal that there are milling slots operations
|
||||||
self.defaults['excellon_drills'] = False
|
self.defaults['excellon_drills'] = False
|
||||||
|
|
||||||
self.routing_flag = 1
|
self.routing_flag = 0
|
||||||
slot_stop_x = x
|
slot_start_x = x
|
||||||
slot_stop_y = y
|
slot_start_y = y
|
||||||
self.slots.append(
|
|
||||||
{
|
|
||||||
'start': Point(slot_start_x, slot_start_y),
|
|
||||||
'stop': Point(slot_stop_x, slot_stop_y),
|
|
||||||
'tool': current_tool
|
|
||||||
}
|
|
||||||
)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if self.match_routing_start is None and self.match_routing_stop is None:
|
if self.routing_flag == 0:
|
||||||
if repeat == 0:
|
if len(re.findall("G01", eline)) > 0:
|
||||||
|
self.match_routing_stop = 'G01'
|
||||||
|
|
||||||
|
# signal that there are milling slots operations
|
||||||
|
self.defaults['excellon_drills'] = False
|
||||||
|
|
||||||
|
self.routing_flag = 1
|
||||||
|
slot_stop_x = x
|
||||||
|
slot_stop_y = y
|
||||||
|
self.slots.append(
|
||||||
|
{
|
||||||
|
'start': Point(slot_start_x, slot_start_y),
|
||||||
|
'stop': Point(slot_stop_x, slot_stop_y),
|
||||||
|
'tool': current_tool
|
||||||
|
}
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if self.match_routing_start is None and self.match_routing_stop is None:
|
||||||
# signal that there are drill operations
|
# signal that there are drill operations
|
||||||
self.defaults['excellon_drills'] = True
|
self.defaults['excellon_drills'] = True
|
||||||
self.drills.append({'point': Point((x, y)), 'tool': current_tool})
|
self.drills.append({'point': Point((x, y)), 'tool': current_tool})
|
||||||
else:
|
# log.debug("{:15} {:8} {:8}".format(eline, x, y))
|
||||||
coordx = x
|
continue
|
||||||
coordy = y
|
|
||||||
while repeat > 0:
|
|
||||||
if repeating_x:
|
|
||||||
coordx = (repeat * x) + repeating_x
|
|
||||||
if repeating_y:
|
|
||||||
coordy = (repeat * y) + repeating_y
|
|
||||||
self.drills.append({'point': Point((coordx, coordy)), 'tool': current_tool})
|
|
||||||
repeat -= 1
|
|
||||||
repeating_x = repeating_y = 0
|
|
||||||
# log.debug("{:15} {:8} {:8}".format(eline, x, y))
|
|
||||||
continue
|
|
||||||
|
|
||||||
# ## Coordinates with period: Use literally. # ##
|
# ## Coordinates with period: Use literally. # ##
|
||||||
match = self.coordsperiod_re.search(eline)
|
match = self.coordsperiod_re.search(eline)
|
||||||
|
|
Loading…
Reference in New Issue