Write each plate's own filaments into a sliced 3MF (#17815)

Exporting all sliced plates put every plate's filament ids and colors into the selected plate's Metadata/plate_N.json, and left the other plates' lists empty. export_3mf now indexes the bounding-box data by each plate's own index.

That data stays on the plate between exports, and the writer adds a plate_N.json for every plate that has it. So the export clears every plate's filament lists first, then fills in the plates it exports. Plates left out of an export get empty lists, and repeat exports don't duplicate entries.
This commit is contained in:
Kris Austin authored and GitHub committed 2026-11-23 15:59:10 -06:00
1 parent 821b602c4d
commit bf86aeae79
1 file changed
+12 -5
+12 -5
View File
@@ -21172,10 +21172,19 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
// The printer reads slice_info.config and knows only its own catalog ids.
auto* id_agent = preset_bundle.is_bbl_vendor() ? wxGetApp().getAgent() : nullptr;
// The bbox data outlives an export, so plates left out of this one must not keep a previous export's filaments.
for (PlateBBoxData* bbox : store_params.id_bboxes) {
bbox->filament_ids.clear();
bbox->filament_colors.clear();
}
for (int i = 0; i < plate_data_list.size(); i++) {
PlateData *plate_data = plate_data_list[i];
plate_data->printer_model_id = printer_model_id;
plate_data->nozzle_diameters = nozzle_diameter_str;
PlateBBoxData* plate_bbox = nullptr;
if (plate_data->is_sliced_valid && plate_data->plate_index >= 0 && plate_data->plate_index < (int) store_params.id_bboxes.size())
plate_bbox = store_params.id_bboxes[plate_data->plate_index];
for (auto it = plate_data->slice_filaments_info.begin(); it != plate_data->slice_filaments_info.end(); it++) {
std::string display_filament_type;
it->type = cfg.get_filament_type(display_filament_type, it->id);
@@ -21183,11 +21192,9 @@ int Plater::export_3mf(const boost::filesystem::path& output_path, SaveStrategy
if (id_agent)
it->filament_id = id_agent->from_orca_filament_id(it->filament_id);
it->color = filament_color ? filament_color->get_at(it->id) : "#FFFFFF";
// save filament info used in curr plate
int index = p->partplate_list.get_curr_plate_index();
if (store_params.id_bboxes.size() > index) {
store_params.id_bboxes[index]->filament_ids.push_back(it->id);
store_params.id_bboxes[index]->filament_colors.push_back(it->color);
if (plate_bbox) {
plate_bbox->filament_ids.push_back(it->id);
plate_bbox->filament_colors.push_back(it->color);
}
}
}