diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index d755f0b2e..28aadc045 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -641,10 +641,18 @@ bool CLI::export_models(IO::ExportFormat format) const std::string path = this->output_filepath(model, format); bool success = false; switch (format) { +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + case IO::AMF: success = Slic3r::store_amf(path.c_str(), &model, nullptr, false); break; +#else case IO::AMF: success = Slic3r::store_amf(path.c_str(), &model, nullptr); break; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF case IO::OBJ: success = Slic3r::store_obj(path.c_str(), &model); break; case IO::STL: success = Slic3r::store_stl(path.c_str(), &model, true); break; +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + case IO::TMF: success = Slic3r::store_3mf(path.c_str(), &model, nullptr, false); break; +#else case IO::TMF: success = Slic3r::store_3mf(path.c_str(), &model, nullptr); break; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF default: assert(false); break; } if (success) diff --git a/src/libslic3r/Format/3mf.cpp b/src/libslic3r/Format/3mf.cpp index 44e12db86..cca90b463 100644 --- a/src/libslic3r/Format/3mf.cpp +++ b/src/libslic3r/Format/3mf.cpp @@ -1876,12 +1876,24 @@ namespace Slic3r { typedef std::vector BuildItemsList; typedef std::map IdToObjectDataMap; +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + bool m_fullpath_sources{ true }; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + public: +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +#if ENABLE_THUMBNAIL_GENERATOR + bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data = nullptr); +#else + bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources); +#endif // ENABLE_THUMBNAIL_GENERATOR +#else #if ENABLE_THUMBNAIL_GENERATOR bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail_data = nullptr); #else bool save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config); #endif // ENABLE_THUMBNAIL_GENERATOR +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF private: #if ENABLE_THUMBNAIL_GENERATOR @@ -1906,6 +1918,22 @@ namespace Slic3r { bool _add_custom_gcode_per_print_z_file_to_archive(mz_zip_archive& archive, Model& model); }; +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +#if ENABLE_THUMBNAIL_GENERATOR + bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data) + { + clear_errors(); + m_fullpath_sources = fullpath_sources; + return _save_model_to_file(filename, model, config, thumbnail_data); + } +#else + bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, bool fullpath_sources) + { + clear_errors(); + return _save_model_to_file(filename, model, config); + } +#endif // ENABLE_THUMBNAIL_GENERATOR +#else #if ENABLE_THUMBNAIL_GENERATOR bool _3MF_Exporter::save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail_data) { @@ -1919,6 +1947,7 @@ namespace Slic3r { return _save_model_to_file(filename, model, config); } #endif // ENABLE_THUMBNAIL_GENERATOR +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF #if ENABLE_THUMBNAIL_GENERATOR bool _3MF_Exporter::_save_model_to_file(const std::string& filename, Model& model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail_data) @@ -2557,7 +2586,12 @@ namespace Slic3r { // stores volume's source data if (!volume->source.input_file.empty()) { +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + std::string input_file = xml_escape(m_fullpath_sources ? volume->source.input_file : boost::filesystem::path(volume->source.input_file).filename().string()); + stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << SOURCE_FILE_KEY << "\" " << VALUE_ATTR << "=\"" << input_file << "\"/>\n"; +#else stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << SOURCE_FILE_KEY << "\" " << VALUE_ATTR << "=\"" << xml_escape(volume->source.input_file) << "\"/>\n"; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << SOURCE_OBJECT_ID_KEY << "\" " << VALUE_ATTR << "=\"" << volume->source.object_idx << "\"/>\n"; stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << SOURCE_VOLUME_ID_KEY << "\" " << VALUE_ATTR << "=\"" << volume->source.volume_idx << "\"/>\n"; stream << " <" << METADATA_TAG << " " << TYPE_ATTR << "=\"" << VOLUME_TYPE << "\" " << KEY_ATTR << "=\"" << SOURCE_OFFSET_X_KEY << "\" " << VALUE_ATTR << "=\"" << volume->source.mesh_offset(0) << "\"/>\n"; @@ -2646,21 +2680,37 @@ bool load_3mf(const char* path, DynamicPrintConfig* config, Model* model, bool c return res; } +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +#if ENABLE_THUMBNAIL_GENERATOR +bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data) +#else +bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources) +#endif // ENABLE_THUMBNAIL_GENERATOR +#else #if ENABLE_THUMBNAIL_GENERATOR bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail_data) #else bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config) #endif // ENABLE_THUMBNAIL_GENERATOR +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF { if ((path == nullptr) || (model == nullptr)) return false; _3MF_Exporter exporter; +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +#if ENABLE_THUMBNAIL_GENERATOR + bool res = exporter.save_model_to_file(path, *model, config, fullpath_sources, thumbnail_data); +#else + bool res = exporter.save_model_to_file(path, *model, config, fullpath_sources); +#endif // ENABLE_THUMBNAIL_GENERATOR +#else #if ENABLE_THUMBNAIL_GENERATOR bool res = exporter.save_model_to_file(path, *model, config, thumbnail_data); #else bool res = exporter.save_model_to_file(path, *model, config); #endif // ENABLE_THUMBNAIL_GENERATOR +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF if (!res) exporter.log_errors(); diff --git a/src/libslic3r/Format/3mf.hpp b/src/libslic3r/Format/3mf.hpp index 2e85b7f59..c28716fff 100644 --- a/src/libslic3r/Format/3mf.hpp +++ b/src/libslic3r/Format/3mf.hpp @@ -31,11 +31,19 @@ namespace Slic3r { // Save the given model and the config data contained in the given Print into a 3mf file. // The model could be modified during the export process if meshes are not repaired or have no shared vertices +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +#if ENABLE_THUMBNAIL_GENERATOR + extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources, const ThumbnailData* thumbnail_data = nullptr); +#else + extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources); +#endif // ENABLE_THUMBNAIL_GENERATOR +#else #if ENABLE_THUMBNAIL_GENERATOR extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config, const ThumbnailData* thumbnail_data = nullptr); #else extern bool store_3mf(const char* path, Model* model, const DynamicPrintConfig* config); #endif // ENABLE_THUMBNAIL_GENERATOR +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF }; // namespace Slic3r diff --git a/src/libslic3r/Format/AMF.cpp b/src/libslic3r/Format/AMF.cpp index 5b65d8fa2..947c04458 100644 --- a/src/libslic3r/Format/AMF.cpp +++ b/src/libslic3r/Format/AMF.cpp @@ -1019,7 +1019,11 @@ bool load_amf(const char* path, DynamicPrintConfig* config, Model* model, bool c return false; } +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +bool store_amf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources) +#else bool store_amf(const char *path, Model *model, const DynamicPrintConfig *config) +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF { if ((path == nullptr) || (model == nullptr)) return false; @@ -1177,7 +1181,12 @@ bool store_amf(const char *path, Model *model, const DynamicPrintConfig *config) stream << "\n"; if (!volume->source.input_file.empty()) { +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + std::string input_file = xml_escape(fullpath_sources ? volume->source.input_file : boost::filesystem::path(volume->source.input_file).filename().string()); + stream << " " << input_file << "\n"; +#else stream << " " << xml_escape(volume->source.input_file) << "\n"; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF stream << " " << volume->source.object_idx << "\n"; stream << " " << volume->source.volume_idx << "\n"; stream << " " << volume->source.mesh_offset(0) << "\n"; diff --git a/src/libslic3r/Format/AMF.hpp b/src/libslic3r/Format/AMF.hpp index 1206d60d0..7404e1e90 100644 --- a/src/libslic3r/Format/AMF.hpp +++ b/src/libslic3r/Format/AMF.hpp @@ -11,7 +11,11 @@ extern bool load_amf(const char* path, DynamicPrintConfig* config, Model* model, // Save the given model and the config data into an amf file. // The model could be modified during the export process if meshes are not repaired or have no shared vertices +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +extern bool store_amf(const char* path, Model* model, const DynamicPrintConfig* config, bool fullpath_sources); +#else extern bool store_amf(const char *path, Model *model, const DynamicPrintConfig *config); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF }; // namespace Slic3r diff --git a/src/libslic3r/Technologies.hpp b/src/libslic3r/Technologies.hpp index bc3ec6c44..23c516a34 100644 --- a/src/libslic3r/Technologies.hpp +++ b/src/libslic3r/Technologies.hpp @@ -71,5 +71,8 @@ // Enable a modified version of the toolbar textures where all the icons are separated by 1 pixel #define ENABLE_MODIFIED_TOOLBAR_TEXTURES (1 && ENABLE_2_2_0_BETA1) +// Enable configurable paths export (fullpath or not) to 3mf and amf +#define ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF (1 && ENABLE_2_2_0_BETA1) + #endif // _technologies_h_ diff --git a/src/slic3r/GUI/AppConfig.cpp b/src/slic3r/GUI/AppConfig.cpp index eb0a7fca6..bcd79274f 100644 --- a/src/slic3r/GUI/AppConfig.cpp +++ b/src/slic3r/GUI/AppConfig.cpp @@ -61,6 +61,11 @@ void AppConfig::set_defaults() if (get("preset_update").empty()) set("preset_update", "1"); +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + if (get("export_sources_full_pathnames").empty()) + set("export_sources_full_pathnames", "1"); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + // remove old 'use_legacy_opengl' parameter from this config, if present if (!get("use_legacy_opengl").empty()) erase("", "use_legacy_opengl"); diff --git a/src/slic3r/GUI/ConfigWizard.cpp b/src/slic3r/GUI/ConfigWizard.cpp index 265e7f203..75d170b03 100644 --- a/src/slic3r/GUI/ConfigWizard.cpp +++ b/src/slic3r/GUI/ConfigWizard.cpp @@ -765,6 +765,23 @@ PageUpdate::PageUpdate(ConfigWizard *parent) box_presets->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent &event) { this->preset_update = event.IsChecked(); }); } +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +PageReloadFromDisk::PageReloadFromDisk(ConfigWizard* parent) + : ConfigWizardPage(parent, _(L("Reload from disk")), _(L("Reload from disk"))) + , full_pathnames(true) +{ + auto* box_pathnames = new wxCheckBox(this, wxID_ANY, _(L("Export full pathnames of models and parts sources into 3mf and amf files"))); + box_pathnames->SetValue(wxGetApp().app_config->get("export_sources_full_pathnames") == "1"); + append(box_pathnames); + append_text(_(L( + "If enabled, allows the Reload from disk command to automatically find and load the files when invoked.\n" + "If not enabled, the Reload from disk command will ask to select each file using an open file dialog." + ))); + + box_pathnames->Bind(wxEVT_CHECKBOX, [this](wxCommandEvent& event) { this->full_pathnames = event.IsChecked(); }); +} +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + PageMode::PageMode(ConfigWizard *parent) : ConfigWizardPage(parent, _(L("View mode")), _(L("View mode"))) { @@ -1356,6 +1373,9 @@ void ConfigWizard::priv::load_pages() btn_finish->Enable(any_fff_selected || any_sla_selected); index->add_page(page_update); +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + index->add_page(page_reload_from_disk); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF index->add_page(page_mode); index->go_to(former_active); // Will restore the active item/page if possible @@ -1730,6 +1750,11 @@ void ConfigWizard::priv::apply_config(AppConfig *app_config, PresetBundle *prese } app_config->set("version_check", page_update->version_check ? "1" : "0"); app_config->set("preset_update", page_update->preset_update ? "1" : "0"); + +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + app_config->set("export_sources_full_pathnames", page_reload_from_disk->full_pathnames ? "1" : "0"); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + page_mode->serialize_mode(app_config); std::string preferred_model; @@ -1885,6 +1910,9 @@ ConfigWizard::ConfigWizard(wxWindow *parent) p->add_page(p->page_custom = new PageCustom(this)); p->add_page(p->page_update = new PageUpdate(this)); +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + p->add_page(p->page_reload_from_disk = new PageReloadFromDisk(this)); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF p->add_page(p->page_mode = new PageMode(this)); p->add_page(p->page_firmware = new PageFirmware(this)); p->add_page(p->page_bed = new PageBedShape(this)); diff --git a/src/slic3r/GUI/ConfigWizard_private.hpp b/src/slic3r/GUI/ConfigWizard_private.hpp index a90832a3f..3ea5321f8 100644 --- a/src/slic3r/GUI/ConfigWizard_private.hpp +++ b/src/slic3r/GUI/ConfigWizard_private.hpp @@ -301,6 +301,17 @@ struct PageUpdate: ConfigWizardPage PageUpdate(ConfigWizard *parent); }; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +struct PageReloadFromDisk : ConfigWizardPage +{ + bool full_pathnames; + + PageReloadFromDisk(ConfigWizard* parent); +}; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + struct PageMode: ConfigWizardPage { wxRadioButton *radio_simple; @@ -455,6 +466,11 @@ struct ConfigWizard::priv PageMaterials *page_sla_materials = nullptr; PageCustom *page_custom = nullptr; PageUpdate *page_update = nullptr; +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + PageReloadFromDisk *page_reload_from_disk = nullptr; +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF +//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ PageMode *page_mode = nullptr; PageVendors *page_vendors = nullptr; Pages3rdparty pages_3rdparty; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index b0fb3f0e6..fe50466be 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4909,7 +4909,12 @@ void Plater::export_amf() wxBusyCursor wait; bool export_config = true; DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure(); +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1"; + if (Slic3r::store_amf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames)) { +#else if (Slic3r::store_amf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr)) { +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF // Success p->statusbar()->set_status_text(wxString::Format(_(L("AMF file exported to %s")), path)); } else { @@ -4938,6 +4943,16 @@ void Plater::export_3mf(const boost::filesystem::path& output_path) DynamicPrintConfig cfg = wxGetApp().preset_bundle->full_config_secure(); const std::string path_u8 = into_u8(path); wxBusyCursor wait; +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + bool full_pathnames = wxGetApp().app_config->get("export_sources_full_pathnames") == "1"; +#if ENABLE_THUMBNAIL_GENERATOR + ThumbnailData thumbnail_data; + p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, false, true, true, true); + if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames, &thumbnail_data)) { +#else + if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr, full_pathnames)) { +#endif // ENABLE_THUMBNAIL_GENERATOR +#else #if ENABLE_THUMBNAIL_GENERATOR ThumbnailData thumbnail_data; p->generate_thumbnail(thumbnail_data, THUMBNAIL_SIZE_3MF.first, THUMBNAIL_SIZE_3MF.second, false, true, true, true); @@ -4945,6 +4960,7 @@ void Plater::export_3mf(const boost::filesystem::path& output_path) #else if (Slic3r::store_3mf(path_u8.c_str(), &p->model, export_config ? &cfg : nullptr)) { #endif // ENABLE_THUMBNAIL_GENERATOR +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF // Success p->statusbar()->set_status_text(wxString::Format(_(L("3MF file exported to %s")), path)); p->set_project_filename(path); diff --git a/src/slic3r/GUI/Preferences.cpp b/src/slic3r/GUI/Preferences.cpp index 827d1f4e0..295c1a6ec 100644 --- a/src/slic3r/GUI/Preferences.cpp +++ b/src/slic3r/GUI/Preferences.cpp @@ -73,6 +73,16 @@ void PreferencesDialog::build() option = Option (def, "version_check"); m_optgroup->append_single_option_line(option); +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + // Please keep in sync with ConfigWizard + def.label = L("Export sources full pathnames to 3mf and amf"); + def.type = coBool; + def.tooltip = L("If enabled, allows the Reload from disk command to automatically find and load the files when invoked."); + def.set_default_value(new ConfigOptionBool(app_config->get("export_sources_full_pathnames") == "1")); + option = Option(def, "export_sources_full_pathnames"); + m_optgroup->append_single_option_line(option); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + // Please keep in sync with ConfigWizard def.label = L("Update built-in Presets automatically"); def.type = coBool; diff --git a/src/slic3r/Utils/FixModelByWin10.cpp b/src/slic3r/Utils/FixModelByWin10.cpp index b7eb12e02..28f8b54d5 100644 --- a/src/slic3r/Utils/FixModelByWin10.cpp +++ b/src/slic3r/Utils/FixModelByWin10.cpp @@ -363,10 +363,17 @@ void fix_model_by_win10_sdk_gui(ModelObject &model_object, int volume_idx) ModelObject *model_object = model.add_object(); model_object->add_volume(*volumes[ivolume]); model_object->add_instance(); +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + if (!Slic3r::store_3mf(path_src.string().c_str(), &model, nullptr, false)) { + boost::filesystem::remove(path_src); + throw std::runtime_error(L("Export of a temporary 3mf file failed")); + } +#else if (! Slic3r::store_3mf(path_src.string().c_str(), &model, nullptr)) { boost::filesystem::remove(path_src); throw std::runtime_error(L("Export of a temporary 3mf file failed")); } +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF model.clear_objects(); model.clear_materials(); boost::filesystem::path path_dst = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); diff --git a/tests/libslic3r/test_3mf.cpp b/tests/libslic3r/test_3mf.cpp index 5215e2ebd..5f1c74c36 100644 --- a/tests/libslic3r/test_3mf.cpp +++ b/tests/libslic3r/test_3mf.cpp @@ -51,7 +51,11 @@ SCENARIO("Export+Import geometry to/from 3mf file cycle", "[3mf]") { WHEN("model is saved+loaded to/from 3mf file") { // save the model to 3mf file std::string test_file = std::string(TEST_DATA_DIR) + "/test_3mf/prusa.3mf"; +#if ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF + store_3mf(test_file.c_str(), &src_model, nullptr, false); +#else store_3mf(test_file.c_str(), &src_model, nullptr); +#endif // ENABLE_CONFIGURABLE_PATHS_EXPORT_TO_3MF_AND_AMF // load back the model from the 3mf file Model dst_model;