FIX:fix bug of export .gcode.3mf

jira: STUDIO-7292
Change-Id: Ice1d10b48298b3766b879132e7b7d5de6de4da2c
(cherry picked from commit 2f91017fff1606b80932126277d9e393669438fe)
This commit is contained in:
zhou.xu 2024-06-11 14:35:48 +08:00 committed by Lane.Wei
parent bd9d5efff9
commit b6a196a210
3 changed files with 11 additions and 19 deletions

View File

@ -779,6 +779,7 @@ static const FileWildcards file_wildcards_by_type[FT_SIZE] = {
/* FT_OBJ */ { "OBJ files"sv, { ".obj"sv } },
/* FT_AMF */ { "AMF files"sv, { ".amf"sv, ".zip.amf"sv, ".xml"sv } },
/* FT_3MF */ { "3MF files"sv, { ".3mf"sv } },
/* FT_GCODE_3MF */ {"Gcode 3MF files"sv, {".gcode.3mf"sv}},
/* FT_GCODE */ { "G-code files"sv, { ".gcode"sv } },
#ifdef __APPLE__
/* FT_MODEL */

View File

@ -90,6 +90,7 @@ enum FileType
FT_OBJ,
FT_AMF,
FT_3MF,
FT_GCODE_3MF,
FT_GCODE,
FT_MODEL,
FT_PROJECT,

View File

@ -11114,11 +11114,11 @@ void Plater::export_gcode_3mf(bool export_all)
fs::path default_output_file;
AppConfig& appconfig = *wxGetApp().app_config;
std::string start_dir;
default_output_file = into_path(get_export_gcode_filename(".3mf", false, export_all));
default_output_file = into_path(get_export_gcode_filename(".gcode.3mf", false, export_all));
if (default_output_file.empty()) {
try {
start_dir = appconfig.get_last_output_dir("", false);
wxString filename = get_export_gcode_filename(".3mf", true, export_all);
wxString filename = get_export_gcode_filename(".gcode.3mf", true, export_all);
std::string full_filename = start_dir + "/" + filename.utf8_string();
default_output_file = boost::filesystem::path(full_filename);
} catch(...) {
@ -11126,9 +11126,6 @@ void Plater::export_gcode_3mf(bool export_all)
}
}
//BBS replace gcode extension to .gcode.3mf
default_output_file = default_output_file.replace_extension(".gcode.3mf");
//Get a last save path
start_dir = appconfig.get_last_output_dir(default_output_file.parent_path().string(), false);
@ -11136,25 +11133,18 @@ void Plater::export_gcode_3mf(bool export_all)
{
std::string ext = default_output_file.extension().string();
wxFileDialog dlg(this, _L("Save Sliced file as:"),
start_dir,
from_path(default_output_file.filename()),
GUI::file_wildcards(FT_3MF, ext),
start_dir, from_path(default_output_file.filename()), GUI::file_wildcards(FT_GCODE_3MF, ""),
wxFD_SAVE | wxFD_OVERWRITE_PROMPT
);
if (dlg.ShowModal() == wxID_OK) {
output_path = into_path(dlg.GetPath());
ext = output_path.extension().string();
if (ext != ".3mf")
output_path = output_path.string() + ".gcode.3mf";
else {
if (boost::iends_with(output_path.string(), ".gcode")) {
std::string path = output_path.string();
path = path.substr(0, path.size() - 4);
if (path.size() < 6)
output_path = output_path.replace_extension(".gcode.3mf");
else {
std::string extension = path.substr(path.size() - 6);
if (extension != ".gcode") output_path = output_path.replace_extension(".gcode.3mf");
}
path = path.substr(0, path.size() - 6);
output_path = path + ".gcode.3mf";
}
else if (!boost::iends_with(output_path.string(), ".gcode.3mf")) {
output_path = output_path.replace_extension(".gcode.3mf");
}
}
}