From c90884d10ba517a47ae35773dcb1584d7f08e9b4 Mon Sep 17 00:00:00 2001 From: Marcel Rivard Date: Fri, 19 Mar 2021 21:35:06 -0700 Subject: [PATCH] Fixed bugs with single extruder setup. fixed minor bug in tool creation output. --- src/libslic3r/GCode.cpp | 3 ++- src/libslic3r/GCodeWriter.cpp | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 5ccf4d3c556..c1b51de9b10 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1350,7 +1350,8 @@ std::string MixingExtruderLayers::init_mixing_extruders(GCode &gcodegen, Print& for (ModelVolume* mv : instance.model_instance->get_object()->volumes) { uint16_t extruder_id = mv->extruder_id()-1; - if (extruder_id == tool_id) { + // nasty hack + if ((extruder_id == tool_id) || (extruder_id == 65535)) { // found it.. now we just need to get the bounding box of this volume. b_box = instance.model_instance->get_object()->bounding_box(); diff --git a/src/libslic3r/GCodeWriter.cpp b/src/libslic3r/GCodeWriter.cpp index 684b6dd6229..2550b0734b0 100644 --- a/src/libslic3r/GCodeWriter.cpp +++ b/src/libslic3r/GCodeWriter.cpp @@ -403,7 +403,7 @@ std::string GCodeWriter::create_virtual_tool(int tool_id, std::string drives, st { std::ostringstream gcode; if (FLAVOR_IS(gcfRepRap)) - gcode << "M563 P" << tool_id << " D" << drives << " S" << name + gcode << "M563 P" << tool_id << " " << drives << " S" << name << " ; create virtual tool\n"; else gcode << "; create Marlin virtual tool - NOT!\n"; @@ -432,16 +432,23 @@ std::string GCodeWriter::set_tool_mix(int tool_id, std::vector ratios) for (double val : ratios) { gcode << ":" << XYZF_NUM(val); } + gcode << "M164 S" << tool_id << " "; } else if (FLAVOR_IS(gcfMarlin)) { int i=0; - for (double val : ratios) { - gcode << "M163 S" << i << " P" << XYZF_NUM(val) << "\n"; - i++; + if (tool_id == 0) { + // tool 0 is "special" since in a mixing scenario, it's the only one that's real + // so... we just set the mix directly. up to 6 components... at least I think this will work. + //M165 A0.2 B0.4 C0.3 D0.1 H0.0 I0.0 + gcode << "M165 "; + std::string drivers = "ABCDHI"; + int i = 0; + for (double val : ratios) { + gcode << drivers[i++] << XYZF_NUM(val) << " "; + } } - gcode << "M164 S" << tool_id << " "; } - gcode << " ; set mix ratio\n"; + gcode << "; set mix ratio\n"; return gcode.str(); }