From de3de3fd1177219c1177382abf7a7cd716d8969c Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Mon, 6 Mar 2023 10:47:38 +0100 Subject: [PATCH] Fix of discrepancy between G-code placeholder parser current layer index and total number of layers. Fixed for non-sequential print only for now. Partial fix of #9866 --- src/libslic3r/GCode.cpp | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 28c331313b..e841a5c437 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1005,18 +1005,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato std::sort(zs.begin(), zs.end()); m_layer_count += (unsigned int)(object->instances().size() * (std::unique(zs.begin(), zs.end()) - zs.begin())); } - } else { - // Print all objects with the same print_z together. - std::vector zs; - for (auto object : print.objects()) { - zs.reserve(zs.size() + object->layers().size() + object->support_layers().size()); - for (auto layer : object->layers()) - zs.push_back(layer->print_z); - for (auto layer : object->support_layers()) - zs.push_back(layer->print_z); - } - std::sort(zs.begin(), zs.end()); - m_layer_count = (unsigned int)(std::unique(zs.begin(), zs.end()) - zs.begin()); } print.throw_if_canceled(); @@ -1144,6 +1132,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato this->set_extruders(tool_ordering.all_extruders()); // Order object instances using a nearest neighbor search. print_object_instances_ordering = chain_print_object_instances(print); + m_layer_count = tool_ordering.layer_tools().size(); } if (initial_extruder_id == (unsigned int)-1) { // Nothing to print!