fixed a custom filament creation bug (#7965)

fixed a bug with custom filament creation where orca doesnt recognize capitalized letter in 'Nozzle' in the printer name
This commit is contained in:
Azi 2025-01-07 17:09:35 -08:00 committed by GitHub
parent 5f8da1086b
commit 599b0e09eb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -542,21 +542,24 @@ static char* read_json_file(const std::string &preset_path)
} }
static std::string get_printer_nozzle_diameter(std::string printer_name) { static std::string get_printer_nozzle_diameter(std::string printer_name) {
// Create a lowercase version of the printer_name for case-insensitive search
std::string printer_name_lower = printer_name;
std::transform(printer_name_lower.begin(), printer_name_lower.end(), printer_name_lower.begin(), ::tolower);
size_t index = printer_name.find(" nozzle)"); size_t index = printer_name_lower.find(" nozzle)");
if (std::string::npos == index) { if (std::string::npos == index) {
size_t index = printer_name.find(" nozzle"); size_t index = printer_name_lower.find(" nozzle");
if (std::string::npos == index) { if (std::string::npos == index) {
return ""; return "";
} }
std::string nozzle = printer_name.substr(0, index); std::string nozzle = printer_name_lower.substr(0, index);
size_t last_space_index = nozzle.find_last_of(" "); size_t last_space_index = nozzle.find_last_of(" ");
if (std::string::npos == index) { if (std::string::npos == index) {
return ""; return "";
} }
return nozzle.substr(last_space_index + 1); return nozzle.substr(last_space_index + 1);
} else { } else {
std::string nozzle = printer_name.substr(0, index); std::string nozzle = printer_name_lower.substr(0, index);
size_t last_bracket_index = nozzle.find_last_of("("); size_t last_bracket_index = nozzle.find_last_of("(");
if (std::string::npos == index) { if (std::string::npos == index) {
return ""; return "";