Now tool change is cached

parent c9bf3cfc
......@@ -25,6 +25,7 @@ from pymkcam.Toolpath import CORNER_STYLE_EXACT_PATH, CORNER_STYLE_EXACT_STOP, \
CORNER_STYLE_OPTIMIZE_SPEED, CORNER_STYLE_OPTIMIZE_TOLERANCE
DEFAULT_HEADER = (
("M82", "select absolute coordinate system"),
)
......@@ -51,7 +52,6 @@ class MK4duo(pymkcam.Exporters.GCode.BaseGenerator):
sspeed = "10000"
feed = "300"
fast = "3000"
tool_id = 0
def add_header(self):
for command, comment in DEFAULT_HEADER:
......@@ -60,6 +60,7 @@ class MK4duo(pymkcam.Exporters.GCode.BaseGenerator):
self.add_command("G21", "metric")
else:
self.add_command("G20", "imperial")
self.header_added = True
def add_footer(self):
for command, comment in DEFAULT_FOOTER:
......@@ -97,9 +98,9 @@ class MK4duo(pymkcam.Exporters.GCode.BaseGenerator):
self.feed = _render_number(feedrate)
def command_select_tool(self, tool_id):
if self.tool_id > 0 and self.tool_id != tool_id:
if self._last_tool_id > 0 and self._last_tool_id != tool_id:
self.add_command("T%d" % tool_id, "select tool")
self.tool_id = tool_id
self._last_tool_id = tool_id
def command_spindle_speed(self, speed):
self.sspeed = _render_number(speed)
......
......@@ -46,6 +46,7 @@ class BaseGenerator(object):
self._close_stream_on_exit = False
self._filters = []
self._cache = {}
self._last_tool_id = 0
self.add_header()
def _get_cache(self, key, default_value):
......@@ -79,7 +80,6 @@ class BaseGenerator(object):
all_filters.extend(filters)
filtered_moves = pymkcam.Toolpath.Filters.get_filtered_moves(moves,
all_filters)
_log.info(filtered_moves)
for move_type, args in filtered_moves:
if move_type in (MOVE_STRAIGHT, MOVE_STRAIGHT_RAPID):
is_rapid = move_type == MOVE_STRAIGHT_RAPID
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment