Skip to content

Commit

Permalink
Fixed bugs with single extruder setup. fixed minor bug in tool creati…
Browse files Browse the repository at this point in the history
…on output.
  • Loading branch information
nanoplane committed Mar 20, 2021
1 parent a180596 commit c90884d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
19 changes: 13 additions & 6 deletions src/libslic3r/GCodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -432,16 +432,23 @@ std::string GCodeWriter::set_tool_mix(int tool_id, std::vector<double> 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();
}
Expand Down

0 comments on commit c90884d

Please sign in to comment.