export 3mf file with proper file name.

Issue #32
This commit is contained in:
SoftFever 2022-12-24 13:36:04 +08:00
parent 191a04be16
commit 47c744ceb0

View file

@ -9086,20 +9086,24 @@ void Plater::export_gcode_3mf(bool export_all)
fs::path default_output_file; fs::path default_output_file;
AppConfig& appconfig = *wxGetApp().app_config; AppConfig& appconfig = *wxGetApp().app_config;
std::string start_dir; std::string start_dir;
default_output_file = into_path(get_export_gcode_filename(".3mf", false, export_all)); try {
if (default_output_file.empty()) { // Update the background processing, so that the placeholder parser will get the correct values for the ouput file template.
try { // Also if there is something wrong with the current configuration, a pop-up dialog will be shown and the export will not be performed.
start_dir = appconfig.get_last_output_dir("", false); unsigned int state = this->p->update_restart_background_process(false, false);
wxString filename = get_export_gcode_filename(".3mf", true, export_all); if (state & priv::UPDATE_BACKGROUND_PROCESS_INVALID)
std::string full_filename = start_dir + "/" + filename.utf8_string(); return;
default_output_file = boost::filesystem::path(full_filename); default_output_file = this->p->background_process.output_filepath_for_project("");
} catch(...) {
;
}
} }
catch (const Slic3r::PlaceholderParserError& ex) {
//BBS replace gcode extension to .gcode.3mf // Show the error with monospaced font.
default_output_file = default_output_file.replace_extension(".gcode.3mf"); show_error(this, ex.what(), true);
return;
}
catch (const std::exception& ex) {
show_error(this, ex.what(), false);
return;
}
default_output_file.replace_extension(".3mf");
default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string())); default_output_file = fs::path(Slic3r::fold_utf8_to_ascii(default_output_file.string()));
//Get a last save path //Get a last save path