diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index dd9fab6123..cd94eeaa07 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -706,12 +706,20 @@ namespace Slic3r { 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 + bool found_model = false; for (mz_uint i = 0; i < num_entries; ++i) { if (mz_zip_reader_file_stat(&archive, i, &stat)) { std::string name(stat.m_filename); std::replace(name.begin(), name.end(), '\\', '/'); - if (boost::algorithm::istarts_with(name, MODEL_FOLDER) && boost::algorithm::iends_with(name, MODEL_EXTENSION)) { + if (boost::algorithm::iends_with(name, MODEL_EXTENSION)) { + if(found_model){ + close_zip_reader(&archive); + add_error("3mf contain multiple .model files and it is not supported yet."); + return false; + } + found_model = true; + try { // valid model name -> extract model @@ -730,6 +738,11 @@ namespace Slic3r { } } } + if (!found_model) { + close_zip_reader(&archive); + add_error("Not valid 3mf. There is missing .model file."); + return false; + } // we then loop again the entries to read other files stored in the archive for (mz_uint i = 0; i < num_entries; ++i) { @@ -3574,11 +3587,11 @@ bool load_3mf(const char* path, DynamicPrintConfig& config, ConfigSubstitutionCo // All import should use "C" locales for number formatting. CNumericLocalesSetter locales_setter; _3MF_Importer importer; - importer.load_model_from_file(path, *model, config, config_substitutions, check_version); + bool res = importer.load_model_from_file(path, *model, config, config_substitutions, check_version); importer.log_errors(); handle_legacy_project_loaded(importer.version(), config, importer.prusaslicer_generator_version()); - return !model->objects.empty() || !config.empty(); + return res; } bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data, bool zip64)