From fb1334af858ee048fa60a87f9953c8a3388c72a3 Mon Sep 17 00:00:00 2001 From: enricoturri1966 Date: Mon, 23 Aug 2021 11:23:31 +0200 Subject: [PATCH] #5798 - Fixed naming of single part objects when loaded from 3mf files produced by 3rd part softwares --- src/libslic3r/Format/3mf.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index 2a76f218f..ed2d5d9c3 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -595,7 +595,7 @@ namespace Slic3r { mz_zip_archive_file_stat stat; - m_name = boost::filesystem::path(filename).filename().stem().string(); + m_name = boost::filesystem::path(filename).stem().string(); // we first loop the entries to read from the archive the .model file only, in order to extract the version from it for (mz_uint i = 0; i < num_entries; ++i) { @@ -1408,6 +1408,13 @@ namespace Slic3r { m_model->delete_object(model_object); } + if (m_version == 0) { + // if the 3mf was not produced by PrusaSlicer and there is only one object, + // set the object name to match the filename + if (m_model->objects.size() == 1) + m_model->objects.front()->name = m_name; + } + // applies instances' matrices for (Instance& instance : m_instances) { if (instance.instance != nullptr && instance.instance->get_object() != nullptr)