mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 08:36:26 +03:00
Fix and Improve 3MF impOrt (#13403)
This commit is contained in:
@@ -5992,11 +5992,24 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
|
||||
// BBS: version check
|
||||
Semver app_version = *(Semver::parse(SoftFever_VERSION));
|
||||
const wxString load_3mf_title = _L("Load 3MF");
|
||||
const wxString newer_3mf_title = _L("Newer 3MF version");
|
||||
const wxString bambu_project_title = _L("BambuStudio Project");
|
||||
const wxString msg_unsupported_geometry = _L("The 3MF is not supported by OrcaSlicer, loading geometry data only.");
|
||||
const wxString msg_old_orca_geometry = _L("The 3MF file was generated by an old OrcaSlicer version, loading geometry data only.");
|
||||
const wxString msg_older_geometry = _L("The 3MF file was generated by an older version, loading geometry data only.");
|
||||
const wxString msg_bambu_geometry = _L("The 3MF file was generated by BambuStudio, loading geometry data only.");
|
||||
auto log_and_show_3mf_info = [&](const wxString& text, const wxString& title) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__
|
||||
<< " "
|
||||
<< boost::format("3MF import message [%1%]: %2% | file: %3%") % into_u8(title) % into_u8(text) % path.string();
|
||||
show_info(q, text, title);
|
||||
};
|
||||
if (en_3mf_file_type == En3mfType::From_Prusa) {
|
||||
// do not reset the model config
|
||||
load_config = false;
|
||||
if(load_type != LoadType::LoadGeometry)
|
||||
show_info(q, _L("The 3MF is not supported by OrcaSlicer, loading geometry data only."), _L("Load 3MF"));
|
||||
if (load_type != LoadType::LoadGeometry)
|
||||
log_and_show_3mf_info(msg_unsupported_geometry, load_3mf_title);
|
||||
}
|
||||
else if (en_3mf_file_type == En3mfType::From_Orca) {
|
||||
// OrcaSlicer file (has OrcaSlicer tag) - compare file_version with SoftFever_VERSION
|
||||
@@ -6032,7 +6045,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
wxString append = _L("You'd better upgrade your software.\n");
|
||||
context += "\n\n";
|
||||
context += append;
|
||||
show_info(q, context, _L("Newer 3MF version"));
|
||||
log_and_show_3mf_info(context, newer_3mf_title);
|
||||
}
|
||||
else {
|
||||
//if the minor version is not matched
|
||||
@@ -6040,13 +6053,13 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
wxString text = wxString::Format(_L("The 3MF file version %s is newer than %s's version %s, we suggest to upgrade your software."),
|
||||
file_version.to_string_sf(), std::string(SLIC3R_APP_FULL_NAME), app_version.to_string_sf());
|
||||
text += "\n";
|
||||
show_info(q, text, _L("Newer 3MF version"));
|
||||
log_and_show_3mf_info(text, newer_3mf_title);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (load_config && config_loaded.empty()) {
|
||||
load_config = false;
|
||||
show_info(q, _L("The 3MF file was generated by an old OrcaSlicer version, loading geometry data only."), _L("Load 3MF"));
|
||||
log_and_show_3mf_info(msg_old_orca_geometry, load_3mf_title);
|
||||
}
|
||||
}
|
||||
else if (en_3mf_file_type == En3mfType::From_BBS) {
|
||||
@@ -6081,7 +6094,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
}
|
||||
else if (load_config && config_loaded.empty()) {
|
||||
load_config = false;
|
||||
show_info(q, _L("The 3MF file was generated by an older version, loading geometry data only."), _L("Load 3MF"));
|
||||
log_and_show_3mf_info(msg_older_geometry, load_3mf_title);
|
||||
}
|
||||
} else {
|
||||
// BambuStudio project (version > 2.3.2 without OrcaSlicer tag)
|
||||
@@ -6089,7 +6102,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
Semver slic3r_version = *(Semver::parse(SLIC3R_VERSION));
|
||||
if (load_config && config_loaded.empty()) {
|
||||
load_config = false;
|
||||
show_info(q, _L("The 3MF file was generated by BambuStudio, loading geometry data only."), _L("Load 3MF"));
|
||||
log_and_show_3mf_info(msg_bambu_geometry, load_3mf_title);
|
||||
}
|
||||
else if (load_config && (file_version > slic3r_version)) {
|
||||
// BambuStudio file version is newer than our compatible SLIC3R_VERSION
|
||||
@@ -6101,23 +6114,32 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
wxString append = _L("You'd better upgrade your software.\n");
|
||||
context += "\n\n";
|
||||
context += append;
|
||||
show_info(q, context, _L("BambuStudio Project"));
|
||||
log_and_show_3mf_info(context, bambu_project_title);
|
||||
} else {
|
||||
wxString text = wxString::Format(_L("The 3MF was created by BambuStudio (version %s), which is newer than the compatible version %s. Some settings may not be fully compatible."),
|
||||
file_version.to_string(), slic3r_version.to_string());
|
||||
text += "\n";
|
||||
show_info(q, text, _L("BambuStudio Project"));
|
||||
log_and_show_3mf_info(text, bambu_project_title);
|
||||
}
|
||||
} else if (load_config) {
|
||||
// BambuStudio version is older or same as our SLIC3R_VERSION
|
||||
wxString text = _L("The 3MF was created by BambuStudio. Some settings may differ from OrcaSlicer.");
|
||||
show_info(q, text, _L("BambuStudio Project"));
|
||||
log_and_show_3mf_info(text, bambu_project_title);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (en_3mf_file_type == En3mfType::From_Other) {
|
||||
// Generic CAD/other 3MF without slicer metadata: import geometry silently.
|
||||
if (load_config && config_loaded.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__
|
||||
<< " "
|
||||
<< boost::format("3MF has no slicer metadata/project config, importing geometry only: %1%") % path.string();
|
||||
load_config = false;
|
||||
}
|
||||
}
|
||||
else if (load_config && config_loaded.empty()) {
|
||||
load_config = false;
|
||||
show_info(q, _L("The 3MF file was generated by an old OrcaSlicer version, loading geometry data only."), _L("Load 3MF"));
|
||||
log_and_show_3mf_info(msg_old_orca_geometry, load_3mf_title);
|
||||
}
|
||||
else if (!load_config) {
|
||||
// reset config except color
|
||||
@@ -6207,9 +6229,9 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
config += std::move(config_loaded);
|
||||
std::map<std::string, std::string> validity = config.validate();
|
||||
if (!validity.empty()) {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("Param values in 3mf error: ");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << " " << boost::format("Param values in 3mf error: ");
|
||||
for (std::map<std::string, std::string>::iterator it=validity.begin(); it!=validity.end(); ++it)
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("%1%: %2%")%it->first %it->second;
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << " " << boost::format("%1%: %2%")%it->first %it->second;
|
||||
//
|
||||
NotificationManager *notify_manager = q->get_notification_manager();
|
||||
std::string error_message = L("Invalid values found in the 3MF:");
|
||||
@@ -6691,7 +6713,7 @@ std::vector<size_t> Plater::priv::load_files(const std::vector<fs::path>& input_
|
||||
model_object->center_around_origin(false);
|
||||
|
||||
// BBS
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << boost::format("import 3mf IMPORT_LOAD_MODEL_OBJECTS \n");
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ":" << __LINE__ << " " << boost::format("import 3mf IMPORT_LOAD_MODEL_OBJECTS \n");
|
||||
wxString msg = wxString::Format("Loading file: %s", from_path(real_filename));
|
||||
model_idx++;
|
||||
dlg_cont = dlg.Update(progress_percent, msg);
|
||||
|
||||
Reference in New Issue
Block a user