From d590661d400f0f990d12c88f1d49a1594b153e81 Mon Sep 17 00:00:00 2001
From: Enrico Turri <enricoturri@seznam.cz>
Date: Thu, 8 Nov 2018 10:18:19 +0100
Subject: [PATCH] Fixed objects name after 3mf import

---
 src/libslic3r/Format/3mf.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp
index fc2cf7b89..6e8483949 100644
--- a/src/libslic3r/Format/3mf.cpp
+++ b/src/libslic3r/Format/3mf.cpp
@@ -342,6 +342,7 @@ namespace Slic3r {
         IdToSlaSupportPointsMap m_sla_support_points;
         std::string m_curr_metadata_name;
         std::string m_curr_characters;
+        std::string m_name;
 
     public:
         _3MF_Importer();
@@ -444,6 +445,7 @@ namespace Slic3r {
         , m_unit_factor(1.0f)
         , m_curr_metadata_name("")
         , m_curr_characters("")
+        , m_name("")
     {
     }
 
@@ -505,6 +507,8 @@ namespace Slic3r {
 
         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
         for (mz_uint i = 0; i < num_entries; ++i)
         {
@@ -1051,6 +1055,9 @@ namespace Slic3r {
 
             // set object data
             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);
         }