mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-16 13:32:44 +00:00
Translate filament ids at the printer boundary
Orca content-addresses every system filament, Bambu's included, but a printer, its AMS and its vendor's cloud know only that vendor's own catalog ids. The printer agent now translates between the two: outbound MQTT and FTP traffic, the AMS mapping sent with a print job, and the ids written into a 3mf bound for the printer all leave in the printer's own ids, while status messages, loaded projects and SD-card prints arrive in Orca's. An id with no mapping passes through unchanged, and an agent whose printers already speak Orca's ids translates nothing at all. Bambu's map is generated from BambuStudio's own shipped bundle; a missing or unreadable file leaves every lookup an identity rather than taking the app down. The profile check validates the map's shape, and profile CI now runs on the paths that can change it. docs/HLSD/filament_id.md records the places the map deliberately does not reach.
This commit is contained in:
@@ -100,6 +100,10 @@ using namespace nlohmann;
|
||||
|
||||
#ifdef SLIC3R_GUI
|
||||
#include "slic3r/GUI/GUI_Init.hpp"
|
||||
// BBLPrinterAgent::from_orca_filament_id(); the map and its lookups live in libslic3r_gui,
|
||||
// which only a SLIC3R_GUI build links (see target_link_libraries(OrcaSlicer libslic3r_gui)
|
||||
// in CMakeLists).
|
||||
#include "slic3r/Utils/BBLPrinterAgent.hpp"
|
||||
#endif /* SLIC3R_GUI */
|
||||
|
||||
using namespace Slic3r;
|
||||
@@ -6504,6 +6508,20 @@ int CLI::run(int argc, char **argv)
|
||||
std::string nozzle_diameter_str;
|
||||
if (nozzle_diameter_option)
|
||||
nozzle_diameter_str = nozzle_diameter_option->serialize();
|
||||
#ifdef SLIC3R_GUI
|
||||
// A Bambu printer reads slice_info.config and knows only its own catalog ids. The GUI
|
||||
// gates the same translation on PresetBundle::is_bbl_vendor(); the CLI has no
|
||||
// PresetBundle, so reuse the printer_model prefix that already decides
|
||||
// Print::is_BBL_printer() for this same run.
|
||||
auto* printer_model_option = dynamic_cast<const ConfigOptionString*>(m_print_config.option("printer_model"));
|
||||
const bool is_bbl_printer = printer_model_option && printer_model_option->value.compare(0, 9, "Bambu Lab") == 0;
|
||||
// No wxApp on the CLI path, so there is no live agent to ask; the translator is stateless
|
||||
// over a lazily loaded map, so one instance serves every plate and filament below.
|
||||
// ORCA TODO: this assumes Bambu's is the only agent with a catalog of its own. Once another
|
||||
// agent carries one, resolve the agent from the selected printer the way
|
||||
// GUI_App::resolve_printer_agent_id does, rather than hard-coding BBLPrinterAgent here.
|
||||
const BBLPrinterAgent bbl_agent;
|
||||
#endif /* SLIC3R_GUI */
|
||||
|
||||
for (int i = 0; i < plate_data_list.size(); i++) {
|
||||
PlateData *plate_data = plate_data_list[i];
|
||||
@@ -6520,6 +6538,10 @@ int CLI::run(int argc, char **argv)
|
||||
it->type = m_print_config.get_filament_type(display_filament_type, it->id);
|
||||
it->color = filament_color ? filament_color->get_at(it->id) : "#FFFFFF";
|
||||
it->filament_id = filament_id?filament_id->get_at(it->id):"";
|
||||
#ifdef SLIC3R_GUI
|
||||
if (is_bbl_printer)
|
||||
it->filament_id = bbl_agent.from_orca_filament_id(it->filament_id);
|
||||
#endif /* SLIC3R_GUI */
|
||||
}
|
||||
|
||||
if (!plate_data->plate_thumbnail.is_valid()) {
|
||||
|
||||
Reference in New Issue
Block a user