Fixed objects name after 3mf import

This commit is contained in:
Enrico Turri 2018-11-08 10:18:19 +01:00
parent f1224c64ba
commit d590661d40

View file

@ -342,6 +342,7 @@ namespace Slic3r {
IdToSlaSupportPointsMap m_sla_support_points; IdToSlaSupportPointsMap m_sla_support_points;
std::string m_curr_metadata_name; std::string m_curr_metadata_name;
std::string m_curr_characters; std::string m_curr_characters;
std::string m_name;
public: public:
_3MF_Importer(); _3MF_Importer();
@ -444,6 +445,7 @@ namespace Slic3r {
, m_unit_factor(1.0f) , m_unit_factor(1.0f)
, m_curr_metadata_name("") , m_curr_metadata_name("")
, m_curr_characters("") , m_curr_characters("")
, m_name("")
{ {
} }
@ -505,6 +507,8 @@ namespace Slic3r {
mz_zip_archive_file_stat stat; mz_zip_archive_file_stat stat;
m_name = boost::filesystem::path(filename).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 // 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) for (mz_uint i = 0; i < num_entries; ++i)
{ {
@ -1051,6 +1055,9 @@ namespace Slic3r {
// set object data // set object data
m_curr_object.object->name = get_attribute_value_string(attributes, num_attributes, NAME_ATTR); m_curr_object.object->name = get_attribute_value_string(attributes, num_attributes, NAME_ATTR);
if (m_curr_object.object->name.empty())
m_curr_object.object->name = m_name + "_" + std::to_string(m_model->objects.size());
m_curr_object.id = get_attribute_value_int(attributes, num_attributes, ID_ATTR); m_curr_object.id = get_attribute_value_int(attributes, num_attributes, ID_ATTR);
} }