From 23165b8f3ee730735e1cdc302f4a348534901cc0 Mon Sep 17 00:00:00 2001 From: SoftFever Date: Thu, 6 Apr 2023 15:39:02 +0800 Subject: [PATCH] fix Malformed command issue for Klipper --- src/libslic3r/GCode.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 421c6f7c2a..ad0d3353cd 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2662,12 +2662,16 @@ namespace Skirt { } // namespace Skirt -inline std::string get_instance_name(const PrintObject *object, const PrintInstance &inst) { - return (boost::format("%1%_id_%2%_copy_%3%") % object->model_object()->name % object->get_id() % inst.id).str(); +inline std::string get_instance_name(const PrintObject *object, size_t inst_id) { + auto obj_name = object->model_object()->name; + // replace space in obj_name with '-' + std::replace(obj_name.begin(), obj_name.end(), ' ', '_'); + + return (boost::format("%1%_id_%2%_copy_%3%") % obj_name % object->get_id() % inst_id).str(); } -inline std::string get_instance_name(const PrintObject *object, size_t inst_id) { - return (boost::format("%1%_id_%2%_copy_%3%") % object->model_object()->name % object->get_id() % inst_id).str(); +inline std::string get_instance_name(const PrintObject *object, const PrintInstance &inst) { + return get_instance_name(object, inst.id); } // In sequential mode, process_layer is called once per each object and its copy,