Manage tool change in single gcode exports

parent 76a6b0a9
......@@ -31,8 +31,8 @@ DEFAULT_HEADER = (
DEFAULT_FOOTER = (
("G0 Z5.00000 F200", "safe Z position"),
("M5", "stop spindle"),
#("G0 Z5.00000 F200", "safe Z position"),
#("M5", "stop spindle"),
("M18", "unlock all steppers"),
("M2", "program ends")
)
......@@ -51,7 +51,7 @@ 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:
......@@ -97,7 +97,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:
self.add_command("T%d" % tool_id, "select tool")
self.tool_id = tool_id
def command_spindle_speed(self, speed):
self.sspeed = _render_number(speed)
......
......@@ -79,6 +79,7 @@ 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
......
......@@ -22,6 +22,7 @@ along with pyMKcam. If not, see <http://www.gnu.org/licenses/>.
import pymkcam.Plugins
import pymkcam.Toolpath.Filters as Filters
class TaskTypeMilling(pymkcam.Plugins.PluginBase):
......@@ -62,6 +63,12 @@ class TaskTypeMilling(pymkcam.Plugins.PluginBase):
funcs[key] = self.core.get("get_parameter_sets")(key)\
[environment[key][set_name]]["func"]
tool, tool_filters = funcs["tool"](environment["tool"]["parameters"])
selecttool = False
for tool_filter in tool_filters:
if isinstance(tool_filter, Filters.SelectTool):
selecttool = True
if not selecttool:
tool_filters.insert(0, Filters.SelectTool(task["parameters"]["tool"]["id"]))
low, high = environment["bounds"].get_absolute_limits(
tool_radius=tool.radius, models=environment["collision_models"])
path_generator, motion_grid = funcs["process"](environment["process"],
......
......@@ -232,7 +232,7 @@ class SelectTool(BaseFilter):
index = 0
# skip all non-moves
while (index < len(toolpath)) and \
(not toolpath[0][0] in MOVES_LIST):
((not toolpath[index][0] in MOVES_LIST) or (not not toolpath[index][1][0] == "spindle_enabled")):
index += 1
toolpath.insert(index, (MACHINE_SETTING,
("select_tool", self.settings["tool_id"])))
......
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