#5798 - Fixed naming of single part objects when loaded from 3mf files produced by 3rd part softwares

This commit is contained in:
enricoturri1966 2021-08-23 11:23:31 +02:00
parent 1d6ade1d9c
commit fb1334af85

View File

@ -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)