diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 928ff8a4b0..e2d6f4f0a6 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -977,7 +977,7 @@ static void generic_exception_handle() //#endif } -static std::vector split_str(const std::string& src, const std::string& separator) +std::vector GUI_App::split_str(const std::string& src, const std::string& separator) { size_t pos; size_t start_pos = 0; @@ -997,6 +997,7 @@ void GUI_App::post_init() if (! this->initialized()) throw Slic3r::RuntimeError("Calling post_init() while not yet initialized"); + bool switch_to_3d = false; if (!this->init_params->input_files.empty()) { @@ -1004,21 +1005,19 @@ void GUI_App::post_init() BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format(", init with input files, size %1%, input_gcode %2%") %this->init_params->input_files.size() %this->init_params->input_gcode; - - if (this->init_params->input_files.size() == 1 && boost::starts_with(this->init_params->input_files.front(), "bambustudio://open")) { - auto input_str_arr = split_str(this->init_params->input_files.front(), "bambustudio://open/?file="); - std::string download_origin_url; - for (auto input_str:input_str_arr) { - if (!input_str.empty()) download_origin_url = input_str; + std::string download_params_url = url_decode(this->init_params->input_files.front()); + auto input_str_arr = split_str(download_params_url, "bambustudio://open?file="); + + std::string download_url; + for (auto input_str : input_str_arr) { + if (!input_str.empty()) download_url = input_str; } - - std::string download_file_url = url_decode(download_origin_url); - BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << download_file_url; - if (!download_file_url.empty() && ( boost::starts_with(download_file_url, "http://") || boost::starts_with(download_file_url, "https://")) ) { - request_model_download(download_origin_url); + + if (!download_url.empty() && ( boost::starts_with(download_url, "http://") || boost::starts_with(download_url, "https://")) ) { + request_model_download(download_url); } } else { diff --git a/src/slic3r/GUI/GUI_App.hpp b/src/slic3r/GUI/GUI_App.hpp index 5776ec55c7..e8527d7ee3 100644 --- a/src/slic3r/GUI/GUI_App.hpp +++ b/src/slic3r/GUI/GUI_App.hpp @@ -314,6 +314,7 @@ public: bool is_recreating_gui() const { return m_is_recreating_gui; } std::string logo_name() const { return is_editor() ? "BambuStudio" : "BambuStudio-gcodeviewer"; } + std::vector split_str(const std::string& src, const std::string& separator); // To be called after the GUI is fully built up. // Process command line parameters cached in this->init_params, // load configs, STLs etc. diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 61fead6eed..11f7187a7b 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -7776,14 +7776,31 @@ int Plater::save_project(bool saveAs) //BBS import model by model id void Plater::import_model_id(const std::string& download_info) { + std::string download_origin_url = wxGetApp().url_decode(download_info); + std::string download_url; std::string filename; - std::string download_origin_url = wxGetApp().url_decode(download_info); - fs::path download_path = fs::path(download_origin_url); - download_url = download_origin_url; - filename = download_path.filename().string(); + try + { + std::vector origin_array = wxGetApp().split_str(download_origin_url, "&name="); + if (origin_array.size() >= 2) { + download_url = origin_array[0]; + filename = origin_array[1]; + + } + else if (!download_origin_url.empty()) { + + fs::path download_path = fs::path(download_origin_url); + download_url = download_origin_url; + filename = download_path.filename().string(); + } + } + catch (const std::exception& error) + { + //wxString sError = error.what(); + } bool download_ok = false; /* save to a file */