From 66b619dfa49205ef9f0bac87b0faed3100bfb143 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Wed, 17 May 2017 17:21:55 +0200 Subject: [PATCH] Bugfix of tool ordering. --- xs/src/libslic3r/GCode.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/xs/src/libslic3r/GCode.cpp b/xs/src/libslic3r/GCode.cpp index d17287837..cd18e43e4 100644 --- a/xs/src/libslic3r/GCode.cpp +++ b/xs/src/libslic3r/GCode.cpp @@ -299,13 +299,15 @@ bool GCode::do_export(FILE *file, Print &print) unsigned int initial_extruder_id = (unsigned int)-1; size_t initial_print_object_id = 0; if (print.config.complete_objects.value) { - tool_ordering = ToolOrdering::tool_ordering(print, initial_extruder_id); - initial_extruder_id = ToolOrdering::first_extruder(tool_ordering); - } else { - for (; initial_print_object_id < print.objects.size() && initial_extruder_id == (unsigned int)-1; ++ initial_print_object_id) { - tool_ordering = ToolOrdering::tool_ordering(*print.objects[initial_print_object_id], initial_extruder_id); - initial_extruder_id = ToolOrdering::first_extruder(tool_ordering); - } + // Find the 1st printing object, find its tool ordering and the initial extruder ID. + for (; initial_print_object_id < print.objects.size() && initial_extruder_id == (unsigned int)-1; ++initial_print_object_id) { + tool_ordering = ToolOrdering::tool_ordering(*print.objects[initial_print_object_id], initial_extruder_id); + initial_extruder_id = ToolOrdering::first_extruder(tool_ordering); + } + } else { + // Find tool ordering for all the objects at once, and the initial extruder ID. + tool_ordering = ToolOrdering::tool_ordering(print, initial_extruder_id); + initial_extruder_id = ToolOrdering::first_extruder(tool_ordering); } if (initial_extruder_id == (unsigned int)-1) // Nothing to print!