any2orca 0.4.1 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,482 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * How each PrusaSlicer setting key becomes a Snapmaker Orca one. The table is
4
+ * the decision record: every key a PrusaSlicer project can carry has a rule,
5
+ * and a key without one is a failing test, not a silent passthrough (see
6
+ * keyMap.test.ts, which also checks every target against the settings
7
+ * catalog). The rules are written as pairs so the other direction can reuse
8
+ * the table later.
9
+ *
10
+ * Both slicers descend from Slic3r, so about a third of the keys share a name
11
+ * and a value form. The rest were renamed when Bambu Studio took the Slic3r
12
+ * settings over ("perimeters" became "wall_loops"), changed their value set,
13
+ * or exist on one side only.
14
+ *
15
+ * - `same`: the same key and value form on both sides.
16
+ * - `rename`: a different key, the same value form; `to` may name several
17
+ * keys when Snapmaker Orca keeps one PrusaSlicer value in several places
18
+ * (the bed temperature, which Orca keeps per plate type).
19
+ * - `choices`: a renamed key with a fixed set of values, each mapped; a value
20
+ * not in the map isn't carried, with a warning.
21
+ * - `transform`: a value that needs computing (a percentage resolved to a
22
+ * number, a flag folded into a mode), by name; the code is in
23
+ * convertSettings.ts.
24
+ * - `drop`: no counterpart; reported, so the creator's settings that can't
25
+ * be carried are named.
26
+ * - `machine`: the printer's own (bed shape, G-code, motion limits, host):
27
+ * the U1 profile's values stand, so it's left behind without a report.
28
+ * - `handled`: read by another part of the reader (the color changes, the
29
+ * filament colors), not by the settings map.
30
+ */
31
+ const same = { kind: "same" };
32
+ const machine = { kind: "machine" };
33
+ const handled = { kind: "handled" };
34
+ const rename = (to) => ({ kind: "rename", to });
35
+ const drop = (why) => ({ kind: "drop", why });
36
+ const choices = (to, values) => ({ kind: "choices", to, values });
37
+ const transform = (to, via) => ({ kind: "transform", to, via });
38
+ /** PrusaSlicer's `;`-joined G-code keys carry Prusa's own macros and the source printer's moves; the U1's own G-code is used. */
39
+ const PRUSA_GCODE = "the source printer's G-code; the U1's own is used";
40
+ const NO_COUNTERPART = "no Snapmaker Orca counterpart";
41
+ const INFILL_PATTERNS = {
42
+ rectilinear: "rectilinear",
43
+ alignedrectilinear: "alignedrectilinear",
44
+ grid: "grid",
45
+ triangles: "triangles",
46
+ cubic: "cubic",
47
+ line: "line",
48
+ concentric: "concentric",
49
+ honeycomb: "honeycomb",
50
+ "3dhoneycomb": "3dhoneycomb",
51
+ gyroid: "gyroid",
52
+ hilbertcurve: "hilbertcurve",
53
+ archimedeanchords: "archimedeanchords",
54
+ octagramspiral: "octagramspiral",
55
+ adaptivecubic: "adaptivecubic",
56
+ supportcubic: "supportcubic",
57
+ lightning: "lightning",
58
+ zigzag: "zigzag",
59
+ // PrusaSlicer's "stars" has no Snapmaker Orca pattern; not carried.
60
+ };
61
+ const SURFACE_PATTERNS = {
62
+ rectilinear: "rectilinear",
63
+ monotonic: "monotonic",
64
+ monotoniclines: "monotonicline",
65
+ alignedrectilinear: "alignedrectilinear",
66
+ concentric: "concentric",
67
+ hilbertcurve: "hilbertcurve",
68
+ archimedeanchords: "archimedeanchords",
69
+ octagramspiral: "octagramspiral",
70
+ };
71
+ /**
72
+ * Every key, in PrusaSlicer's own groups: print, filament, printer, then the
73
+ * keys only older PrusaSlicer versions wrote.
74
+ */
75
+ export const PRUSA_KEY_MAP = Object.freeze({
76
+ // ---- Print: layers and perimeters ----
77
+ layer_height: same,
78
+ first_layer_height: transform("initial_layer_print_height", "firstLayerHeight"),
79
+ perimeters: rename("wall_loops"),
80
+ spiral_vase: rename("spiral_mode"),
81
+ slice_closing_radius: same,
82
+ slicing_mode: same,
83
+ resolution: drop("PrusaSlicer's slice resolution; Snapmaker Orca's resolution is the G-code one, taken from gcode_resolution"),
84
+ gcode_resolution: rename("resolution"),
85
+ top_solid_layers: rename("top_shell_layers"),
86
+ bottom_solid_layers: rename("bottom_shell_layers"),
87
+ top_solid_min_thickness: rename("top_shell_thickness"),
88
+ bottom_solid_min_thickness: rename("bottom_shell_thickness"),
89
+ extra_perimeters: drop(NO_COUNTERPART),
90
+ extra_perimeters_on_overhangs: same,
91
+ avoid_crossing_curled_overhangs: drop(NO_COUNTERPART),
92
+ avoid_crossing_perimeters: rename("reduce_crossing_wall"),
93
+ avoid_crossing_perimeters_max_detour: rename("max_travel_detour_distance"),
94
+ only_retract_when_crossing_perimeters: rename("reduce_infill_retraction"),
95
+ thin_walls: rename("detect_thin_wall"),
96
+ thick_bridges: same,
97
+ overhangs: rename("detect_overhang_wall"),
98
+ seam_position: choices("seam_position", { random: "random", nearest: "nearest", aligned: "aligned", rear: "back" }),
99
+ staggered_inner_seams: same,
100
+ seam_gap_distance: rename("seam_gap"),
101
+ scarf_seam_placement: choices("seam_slope_type", { nowhere: "none", contours: "external", everywhere: "all" }),
102
+ scarf_seam_only_on_smooth: rename("seam_slope_conditional"),
103
+ scarf_seam_start_height: rename("seam_slope_start_height"),
104
+ scarf_seam_entire_loop: rename("seam_slope_entire_loop"),
105
+ scarf_seam_length: rename("seam_slope_min_length"),
106
+ scarf_seam_max_segment_length: drop(NO_COUNTERPART),
107
+ scarf_seam_on_inner_perimeters: rename("seam_slope_inner_walls"),
108
+ external_perimeters_first: transform("wall_sequence", "wallSequence"),
109
+ gap_fill_enabled: transform("gap_fill_target", "gapFillTarget"),
110
+ perimeter_generator: rename("wall_generator"),
111
+ wall_transition_length: transform("wall_transition_length", "percentOnly"),
112
+ wall_transition_filter_deviation: transform("wall_transition_filter_deviation", "percentOnly"),
113
+ wall_transition_angle: same,
114
+ wall_distribution_count: same,
115
+ min_feature_size: transform("min_feature_size", "percentOnly"),
116
+ min_bead_width: transform("min_bead_width", "percentOnly"),
117
+ only_one_perimeter_first_layer: rename("only_one_wall_first_layer"),
118
+ top_one_perimeter_type: transform("only_one_wall_top", "onlyOneWallTop"),
119
+ ensure_vertical_shell_thickness: choices("ensure_vertical_shell_thickness", { disabled: "none", partial: "ensure_moderate", enabled: "ensure_all" }),
120
+ interface_shells: same,
121
+ fuzzy_skin: same,
122
+ fuzzy_skin_thickness: same,
123
+ fuzzy_skin_point_dist: rename("fuzzy_skin_point_distance"),
124
+ xy_size_compensation: rename("xy_contour_compensation"),
125
+ elefant_foot_compensation: same,
126
+ mmu_segmented_region_max_width: same,
127
+ mmu_segmented_region_interlocking_depth: same,
128
+ interlocking_beam: same,
129
+ interlocking_beam_width: same,
130
+ interlocking_orientation: same,
131
+ interlocking_beam_layer_count: same,
132
+ interlocking_depth: same,
133
+ interlocking_boundary_avoidance: same,
134
+ // ---- Print: infill ----
135
+ fill_density: rename("sparse_infill_density"),
136
+ fill_pattern: choices("sparse_infill_pattern", INFILL_PATTERNS),
137
+ fill_angle: rename("infill_direction"),
138
+ top_fill_pattern: choices("top_surface_pattern", SURFACE_PATTERNS),
139
+ bottom_fill_pattern: choices("bottom_surface_pattern", SURFACE_PATTERNS),
140
+ infill_every_layers: transform("infill_combination", "infillCombination"),
141
+ automatic_infill_combination: drop(NO_COUNTERPART),
142
+ automatic_infill_combination_max_layer_height: drop(NO_COUNTERPART),
143
+ solid_infill_every_layers: drop(NO_COUNTERPART),
144
+ infill_only_where_needed: drop(NO_COUNTERPART),
145
+ infill_first: rename("is_infill_first"),
146
+ infill_overlap: transform("infill_wall_overlap", "percentOnly"),
147
+ infill_anchor: same,
148
+ infill_anchor_max: same,
149
+ solid_infill_below_area: rename("minimum_sparse_infill_area"),
150
+ bridge_angle: same,
151
+ bridge_flow_ratio: rename("bridge_flow"),
152
+ dont_support_bridges: rename("bridge_no_support"),
153
+ ironing: handled,
154
+ ironing_type: transform("ironing_type", "ironingType"),
155
+ ironing_flowrate: rename("ironing_flow"),
156
+ ironing_spacing: same,
157
+ ironing_speed: same,
158
+ // ---- Print: speeds and accelerations ----
159
+ perimeter_speed: rename("inner_wall_speed"),
160
+ external_perimeter_speed: transform("outer_wall_speed", "percentOfPerimeterSpeed"),
161
+ small_perimeter_speed: same,
162
+ infill_speed: rename("sparse_infill_speed"),
163
+ solid_infill_speed: transform("internal_solid_infill_speed", "percentOfInfillSpeed"),
164
+ top_solid_infill_speed: transform("top_surface_speed", "percentOfSolidInfillSpeed"),
165
+ support_material_speed: rename("support_speed"),
166
+ support_material_interface_speed: transform("support_interface_speed", "percentOfSupportSpeed"),
167
+ bridge_speed: same,
168
+ over_bridge_speed: drop(NO_COUNTERPART),
169
+ gap_fill_speed: rename("gap_infill_speed"),
170
+ travel_speed: same,
171
+ travel_speed_z: same,
172
+ first_layer_speed: transform("initial_layer_speed", "percentOfPerimeterSpeed"),
173
+ first_layer_infill_speed: transform("initial_layer_infill_speed", "percentOfFirstLayerSpeed"),
174
+ first_layer_speed_over_raft: drop(NO_COUNTERPART),
175
+ enable_dynamic_overhang_speeds: rename("enable_overhang_speed"),
176
+ // PrusaSlicer names its four overhang speeds by the overlap with the layer below (0% overlap is a bridge);
177
+ // Snapmaker Orca names its four by the overhang (4/4 is the most overhang). Same four bands, opposite order.
178
+ overhang_speed_0: rename("overhang_4_4_speed"),
179
+ overhang_speed_1: rename("overhang_3_4_speed"),
180
+ overhang_speed_2: rename("overhang_2_4_speed"),
181
+ overhang_speed_3: rename("overhang_1_4_speed"),
182
+ perimeter_acceleration: rename("inner_wall_acceleration"),
183
+ external_perimeter_acceleration: rename("outer_wall_acceleration"),
184
+ infill_acceleration: rename("sparse_infill_acceleration"),
185
+ solid_infill_acceleration: rename("internal_solid_infill_acceleration"),
186
+ top_solid_infill_acceleration: rename("top_surface_acceleration"),
187
+ bridge_acceleration: same,
188
+ first_layer_acceleration: rename("initial_layer_acceleration"),
189
+ first_layer_acceleration_over_raft: drop(NO_COUNTERPART),
190
+ travel_acceleration: same,
191
+ travel_short_distance_acceleration: drop(NO_COUNTERPART),
192
+ wipe_tower_acceleration: drop(NO_COUNTERPART),
193
+ default_acceleration: same,
194
+ max_print_speed: drop(NO_COUNTERPART),
195
+ max_volumetric_speed: drop("PrusaSlicer's print-level cap; the filament's own max volumetric speed is carried"),
196
+ max_volumetric_extrusion_rate_slope_positive: rename("max_volumetric_extrusion_rate_slope"),
197
+ max_volumetric_extrusion_rate_slope_negative: drop("Snapmaker Orca has one extrusion rate slope, taken from the positive one"),
198
+ // ---- Print: skirt, brim, raft ----
199
+ skirts: rename("skirt_loops"),
200
+ skirt_distance: same,
201
+ skirt_height: same,
202
+ draft_shield: choices("draft_shield", { disabled: "disabled", limited: "enabled", enabled: "enabled" }),
203
+ min_skirt_length: same,
204
+ brim_width: same,
205
+ brim_separation: rename("brim_object_gap"),
206
+ brim_type: same,
207
+ raft_layers: same,
208
+ raft_contact_distance: same,
209
+ raft_expansion: same,
210
+ raft_first_layer_density: same,
211
+ raft_first_layer_expansion: same,
212
+ // ---- Print: supports ----
213
+ support_material: rename("enable_support"),
214
+ support_material_auto: transform("support_type", "supportType"),
215
+ support_material_style: choices("support_style", { grid: "grid", snug: "snug", organic: "organic" }),
216
+ support_material_threshold: transform("support_threshold_angle", "supportThreshold"),
217
+ support_material_enforce_layers: rename("enforce_support_layers"),
218
+ support_material_buildplate_only: rename("support_on_build_plate_only"),
219
+ support_material_contact_distance: rename("support_top_z_distance"),
220
+ support_material_bottom_contact_distance: transform("support_bottom_z_distance", "supportBottomZ"),
221
+ support_material_pattern: choices("support_base_pattern", { rectilinear: "rectilinear", "rectilinear-grid": "rectilinear-grid", honeycomb: "honeycomb" }),
222
+ support_material_with_sheath: drop(NO_COUNTERPART),
223
+ support_material_spacing: rename("support_base_pattern_spacing"),
224
+ support_material_angle: rename("support_angle"),
225
+ support_material_closing_radius: drop(NO_COUNTERPART),
226
+ support_material_interface_layers: rename("support_interface_top_layers"),
227
+ support_material_bottom_interface_layers: rename("support_interface_bottom_layers"),
228
+ support_material_interface_contact_loops: rename("support_interface_loop_pattern"),
229
+ support_material_interface_pattern: choices("support_interface_pattern", { auto: "auto", rectilinear: "rectilinear", concentric: "concentric" }),
230
+ support_material_interface_spacing: rename("support_interface_spacing"),
231
+ support_material_xy_spacing: transform("support_object_xy_distance", "supportXySpacing"),
232
+ support_material_synchronize_layers: drop(NO_COUNTERPART),
233
+ support_tree_angle: rename("tree_support_branch_angle"),
234
+ support_tree_angle_slow: rename("tree_support_angle_slow"),
235
+ support_tree_branch_diameter: rename("tree_support_branch_diameter"),
236
+ support_tree_branch_diameter_angle: rename("tree_support_branch_diameter_angle"),
237
+ support_tree_branch_diameter_double_wall: drop(NO_COUNTERPART),
238
+ support_tree_tip_diameter: rename("tree_support_tip_diameter"),
239
+ support_tree_branch_distance: rename("tree_support_branch_distance"),
240
+ support_tree_top_rate: rename("tree_support_top_rate"),
241
+ // ---- Print: extrusion widths and multiple extruders ----
242
+ extrusion_width: rename("line_width"),
243
+ first_layer_extrusion_width: rename("initial_layer_line_width"),
244
+ perimeter_extrusion_width: rename("inner_wall_line_width"),
245
+ external_perimeter_extrusion_width: rename("outer_wall_line_width"),
246
+ infill_extrusion_width: rename("sparse_infill_line_width"),
247
+ solid_infill_extrusion_width: rename("internal_solid_infill_line_width"),
248
+ top_infill_extrusion_width: rename("top_surface_line_width"),
249
+ support_material_extrusion_width: rename("support_line_width"),
250
+ automatic_extrusion_widths: drop(NO_COUNTERPART),
251
+ perimeter_extruder: rename("wall_filament"),
252
+ infill_extruder: rename("sparse_infill_filament"),
253
+ solid_infill_extruder: rename("solid_infill_filament"),
254
+ support_material_extruder: rename("support_filament"),
255
+ support_material_interface_extruder: rename("support_interface_filament"),
256
+ wipe_tower_extruder: rename("wipe_tower_filament"),
257
+ ooze_prevention: same,
258
+ standby_temperature_delta: same,
259
+ wipe_tower: rename("enable_prime_tower"),
260
+ wipe_tower_x: same,
261
+ wipe_tower_y: same,
262
+ wipe_tower_width: rename("prime_tower_width"),
263
+ wipe_tower_rotation_angle: same,
264
+ wipe_tower_brim_width: rename("prime_tower_brim_width"),
265
+ wipe_tower_bridging: same,
266
+ wipe_tower_cone_angle: same,
267
+ wipe_tower_extra_spacing: same,
268
+ wipe_tower_extra_flow: same,
269
+ wipe_tower_no_sparse_layers: same,
270
+ single_extruder_multi_material_priming: same,
271
+ wipe_into_infill: rename("flush_into_infill"),
272
+ wipe_into_objects: rename("flush_into_objects"),
273
+ wiping_volumes_matrix: rename("flush_volumes_matrix"),
274
+ wiping_volumes_use_custom_matrix: drop(NO_COUNTERPART),
275
+ multimaterial_purging: drop(NO_COUNTERPART),
276
+ // ---- Print: output and other ----
277
+ complete_objects: transform("print_sequence", "printSequence"),
278
+ extruder_clearance_height: rename("extruder_clearance_height_to_rod"),
279
+ extruder_clearance_radius: same,
280
+ gcode_comments: same,
281
+ gcode_label_objects: machine,
282
+ output_filename_format: machine,
283
+ post_process: drop("PrusaSlicer's post-processing scripts"),
284
+ notes: same,
285
+ gcode_substitutions: drop("PrusaSlicer's G-code substitutions"),
286
+ arc_fitting: transform("enable_arc_fitting", "arcFitting"),
287
+ prefer_clockwise_movements: drop(NO_COUNTERPART),
288
+ print_settings_id: same,
289
+ inherits_cummulative: machine,
290
+ compatible_printers_condition_cummulative: machine,
291
+ compatible_printers: machine,
292
+ compatible_printers_condition: machine,
293
+ compatible_prints: machine,
294
+ compatible_prints_condition: machine,
295
+ custom_parameters_print: drop("PrusaSlicer's custom G-code parameters"),
296
+ custom_parameters_filament: drop("PrusaSlicer's custom G-code parameters"),
297
+ custom_parameters_printer: drop("PrusaSlicer's custom G-code parameters"),
298
+ colorprint_heights: handled,
299
+ variable_layer_height: handled,
300
+ threads: machine,
301
+ // ---- Filament ----
302
+ filament_colour: transform("filament_colour", "filamentColour"),
303
+ filament_settings_id: same,
304
+ filament_type: transform("filament_type", "filamentType"),
305
+ filament_vendor: same,
306
+ filament_notes: same,
307
+ filament_diameter: same,
308
+ extrusion_multiplier: rename("filament_flow_ratio"),
309
+ filament_density: same,
310
+ filament_cost: same,
311
+ filament_spool_weight: drop(NO_COUNTERPART),
312
+ filament_soluble: same,
313
+ filament_abrasive: drop(NO_COUNTERPART),
314
+ filament_max_volumetric_speed: same,
315
+ filament_infill_max_speed: drop(NO_COUNTERPART),
316
+ filament_infill_max_crossing_speed: drop(NO_COUNTERPART),
317
+ filament_shrinkage_compensation_xy: transform("filament_shrink", "percentComplement"),
318
+ filament_shrinkage_compensation_z: transform("filament_shrinkage_compensation_z", "percentComplement"),
319
+ filament_purge_multiplier: drop(NO_COUNTERPART),
320
+ temperature: rename("nozzle_temperature"),
321
+ first_layer_temperature: rename("nozzle_temperature_initial_layer"),
322
+ bed_temperature: rename(["textured_plate_temp", "hot_plate_temp"]),
323
+ first_layer_bed_temperature: rename(["textured_plate_temp_initial_layer", "hot_plate_temp_initial_layer"]),
324
+ bed_temperature_extruder: drop(NO_COUNTERPART),
325
+ chamber_temperature: same,
326
+ chamber_minimal_temperature: drop(NO_COUNTERPART),
327
+ idle_temperature: same,
328
+ cooling: rename("slow_down_for_layer_cooling"),
329
+ fan_always_on: drop("Snapmaker Orca's minimum fan speed applies throughout"),
330
+ min_fan_speed: rename("fan_min_speed"),
331
+ max_fan_speed: rename("fan_max_speed"),
332
+ bridge_fan_speed: rename("overhang_fan_speed"),
333
+ enable_dynamic_fan_speeds: drop(NO_COUNTERPART),
334
+ overhang_fan_speed_0: drop(NO_COUNTERPART),
335
+ overhang_fan_speed_1: drop(NO_COUNTERPART),
336
+ overhang_fan_speed_2: drop(NO_COUNTERPART),
337
+ overhang_fan_speed_3: drop(NO_COUNTERPART),
338
+ disable_fan_first_layers: rename("close_fan_the_first_x_layers"),
339
+ full_fan_speed_layer: same,
340
+ fan_below_layer_time: rename("fan_cooling_layer_time"),
341
+ slowdown_below_layer_time: rename("slow_down_layer_time"),
342
+ min_print_speed: rename("slow_down_min_speed"),
343
+ cooling_slowdown_logic: drop(NO_COUNTERPART),
344
+ cooling_perimeter_transition_distance: drop(NO_COUNTERPART),
345
+ filament_retract_length: rename("filament_retraction_length"),
346
+ filament_retract_lift: rename("filament_z_hop"),
347
+ filament_retract_lift_above: same,
348
+ filament_retract_lift_below: same,
349
+ filament_retract_speed: rename("filament_retraction_speed"),
350
+ filament_deretract_speed: rename("filament_deretraction_speed"),
351
+ filament_retract_restart_extra: same,
352
+ filament_retract_before_travel: rename("filament_retraction_minimum_travel"),
353
+ filament_retract_layer_change: rename("filament_retract_when_changing_layer"),
354
+ filament_wipe: same,
355
+ filament_retract_before_wipe: same,
356
+ filament_retract_length_toolchange: same,
357
+ filament_retract_restart_extra_toolchange: same,
358
+ filament_seam_gap_distance: drop(NO_COUNTERPART),
359
+ filament_travel_ramping_lift: drop(NO_COUNTERPART),
360
+ filament_travel_slope: drop(NO_COUNTERPART),
361
+ filament_travel_max_lift: drop(NO_COUNTERPART),
362
+ filament_travel_lift_before_obstacle: drop(NO_COUNTERPART),
363
+ filament_loading_speed: same,
364
+ filament_loading_speed_start: same,
365
+ filament_unloading_speed: same,
366
+ filament_unloading_speed_start: same,
367
+ filament_load_time: same,
368
+ filament_unload_time: same,
369
+ filament_toolchange_delay: same,
370
+ filament_cooling_moves: same,
371
+ filament_cooling_initial_speed: same,
372
+ filament_cooling_final_speed: same,
373
+ filament_stamping_distance: same,
374
+ filament_stamping_loading_speed: same,
375
+ filament_minimal_purge_on_wipe_tower: same,
376
+ filament_multitool_ramming: same,
377
+ filament_multitool_ramming_volume: same,
378
+ filament_multitool_ramming_flow: same,
379
+ filament_ramming_parameters: same,
380
+ filament_flush_speed: drop(NO_COUNTERPART),
381
+ filament_flush_volume: drop(NO_COUNTERPART),
382
+ start_filament_gcode: drop(PRUSA_GCODE),
383
+ end_filament_gcode: drop(PRUSA_GCODE),
384
+ // ---- Printer ----
385
+ printer_model: same,
386
+ printer_settings_id: same,
387
+ printer_variant: same,
388
+ printer_vendor: machine,
389
+ printer_notes: same,
390
+ printer_technology: same,
391
+ physical_printer_settings_id: machine,
392
+ bed_shape: machine,
393
+ bed_custom_model: machine,
394
+ bed_custom_texture: machine,
395
+ max_print_height: machine,
396
+ max_layer_height: machine,
397
+ min_layer_height: machine,
398
+ duplicate_distance: machine,
399
+ z_offset: machine,
400
+ nozzle_diameter: same,
401
+ nozzle_high_flow: machine,
402
+ extruder_offset: machine,
403
+ extruder_colour: handled,
404
+ gcode_flavor: machine,
405
+ binary_gcode: machine,
406
+ autoemit_temperature_commands: machine,
407
+ use_relative_e_distances: machine,
408
+ use_firmware_retraction: machine,
409
+ use_volumetric_e: machine,
410
+ extrusion_axis: machine,
411
+ remaining_times: machine,
412
+ silent_mode: machine,
413
+ machine_limits_usage: machine,
414
+ machine_max_acceleration_e: machine,
415
+ machine_max_acceleration_extruding: machine,
416
+ machine_max_acceleration_retracting: machine,
417
+ machine_max_acceleration_travel: machine,
418
+ machine_max_acceleration_x: machine,
419
+ machine_max_acceleration_y: machine,
420
+ machine_max_acceleration_z: machine,
421
+ machine_max_feedrate_e: machine,
422
+ machine_max_feedrate_x: machine,
423
+ machine_max_feedrate_y: machine,
424
+ machine_max_feedrate_z: machine,
425
+ machine_max_jerk_e: machine,
426
+ machine_max_jerk_x: machine,
427
+ machine_max_jerk_y: machine,
428
+ machine_max_jerk_z: machine,
429
+ machine_max_junction_deviation: machine,
430
+ machine_min_extruding_rate: machine,
431
+ machine_min_travel_rate: machine,
432
+ retract_length: rename("retraction_length"),
433
+ retract_lift: rename("z_hop"),
434
+ retract_lift_above: same,
435
+ retract_lift_below: same,
436
+ retract_speed: rename("retraction_speed"),
437
+ deretract_speed: rename("deretraction_speed"),
438
+ retract_restart_extra: same,
439
+ retract_before_travel: rename("retraction_minimum_travel"),
440
+ retract_layer_change: rename("retract_when_changing_layer"),
441
+ wipe: same,
442
+ retract_before_wipe: same,
443
+ retract_length_toolchange: same,
444
+ retract_restart_extra_toolchange: same,
445
+ travel_ramping_lift: transform("z_hop_types", "zHopTypes"),
446
+ travel_slope: same,
447
+ travel_max_lift: drop(NO_COUNTERPART),
448
+ travel_lift_before_obstacle: drop(NO_COUNTERPART),
449
+ single_extruder_multi_material: machine,
450
+ cooling_tube_retraction: same,
451
+ cooling_tube_length: same,
452
+ parking_pos_retraction: same,
453
+ extra_loading_move: same,
454
+ high_current_on_filament_swap: same,
455
+ toolchange_ordering: drop(NO_COUNTERPART),
456
+ start_gcode: machine,
457
+ end_gcode: machine,
458
+ before_layer_gcode: machine,
459
+ layer_gcode: machine,
460
+ toolchange_gcode: machine,
461
+ between_objects_gcode: machine,
462
+ color_change_gcode: machine,
463
+ pause_print_gcode: machine,
464
+ template_custom_gcode: machine,
465
+ host_type: machine,
466
+ thumbnails: machine,
467
+ thumbnails_format: machine,
468
+ default_print_profile: machine,
469
+ default_filament_profile: machine,
470
+ // ---- Written only by older PrusaSlicer versions ----
471
+ build_prepare_time: machine,
472
+ enable_pressure_advance: same,
473
+ pressure_advance: same,
474
+ filament_type_sub: drop(NO_COUNTERPART),
475
+ is_mmu: machine,
476
+ post_process_enable: drop("PrusaSlicer's post-processing scripts"),
477
+ wiping_volumes_extruders: drop("PrusaSlicer's older purge volumes; the matrix is carried"),
478
+ clip_multipart_objects: drop(NO_COUNTERPART),
479
+ gcode_binary: machine,
480
+ serial_port: machine,
481
+ serial_speed: machine,
482
+ });
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Reads `Metadata/Slic3r_PE_model.config`, where PrusaSlicer keeps what the
3
+ * 3MF model file can't: each object's name and per-object settings, and each
4
+ * of its volumes (parts and modifiers) with the triangle range it owns in the
5
+ * object's single mesh, its filament (`extruder`), its matrix, and any
6
+ * per-volume settings.
7
+ *
8
+ * ```xml
9
+ * <config>
10
+ * <object id="1" instances_count="1">
11
+ * <metadata type="object" key="name" value="Shape-Box"/>
12
+ * <metadata type="object" key="extruder" value="2"/>
13
+ * <volume firstid="0" lastid="11">
14
+ * <metadata type="volume" key="name" value="Shape-Box"/>
15
+ * <metadata type="volume" key="volume_type" value="ModelPart"/>
16
+ * <metadata type="volume" key="extruder" value="0"/>
17
+ * <mesh .../>
18
+ * </volume>
19
+ * </object>
20
+ * </config>
21
+ * ```
22
+ *
23
+ * PrusaSlicer's own XML writer produces this, so a small reader for exactly
24
+ * that shape is enough; it's untrusted input all the same, so everything is
25
+ * bounded and anything unexpected is skipped, never trusted.
26
+ */
27
+ export interface PrusaVolume {
28
+ /** The triangle range of this volume in the object's mesh, inclusive. */
29
+ firstTriangle: number;
30
+ lastTriangle: number;
31
+ /** "ModelPart", "NegativeVolume", "ParameterModifier", "SupportEnforcer", "SupportBlocker"; a part when unsaid. */
32
+ volumeType: string;
33
+ /** The filament slot, 1-based; 0 (PrusaSlicer's "default") means the object's. */
34
+ extruder: number;
35
+ name: string;
36
+ /** Per-volume settings besides the ones above, as written (PrusaSlicer keys). */
37
+ settings: Map<string, string>;
38
+ }
39
+ export interface PrusaObject {
40
+ /** The object id, as in the model file's `<object id>`. */
41
+ id: number;
42
+ name: string;
43
+ /** The filament slot, 1-based; 0 means the printer's default (filament 1). */
44
+ extruder: number;
45
+ volumes: PrusaVolume[];
46
+ /** Per-object settings besides the ones above, as written (PrusaSlicer keys). */
47
+ settings: Map<string, string>;
48
+ }
49
+ /** Every object in the config, in file order; an object without a usable id is skipped. */
50
+ export declare function parsePrusaModelConfig(xml: string): PrusaObject[];
@@ -0,0 +1,83 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Reads `Metadata/Slic3r_PE_model.config`, where PrusaSlicer keeps what the
4
+ * 3MF model file can't: each object's name and per-object settings, and each
5
+ * of its volumes (parts and modifiers) with the triangle range it owns in the
6
+ * object's single mesh, its filament (`extruder`), its matrix, and any
7
+ * per-volume settings.
8
+ *
9
+ * ```xml
10
+ * <config>
11
+ * <object id="1" instances_count="1">
12
+ * <metadata type="object" key="name" value="Shape-Box"/>
13
+ * <metadata type="object" key="extruder" value="2"/>
14
+ * <volume firstid="0" lastid="11">
15
+ * <metadata type="volume" key="name" value="Shape-Box"/>
16
+ * <metadata type="volume" key="volume_type" value="ModelPart"/>
17
+ * <metadata type="volume" key="extruder" value="0"/>
18
+ * <mesh .../>
19
+ * </volume>
20
+ * </object>
21
+ * </config>
22
+ * ```
23
+ *
24
+ * PrusaSlicer's own XML writer produces this, so a small reader for exactly
25
+ * that shape is enough; it's untrusted input all the same, so everything is
26
+ * bounded and anything unexpected is skipped, never trusted.
27
+ */
28
+ const MAX_OBJECTS = 10_000;
29
+ const MAX_VOLUMES = 10_000;
30
+ /** Metadata keys that aren't settings: identity and the volume's own bookkeeping. */
31
+ const NOT_SETTINGS = new Set(["name", "extruder", "volume_type", "matrix", "source_file", "source_object_id", "source_volume_id", "source_offset_x", "source_offset_y", "source_offset_z", "source_in_inches", "source_in_meters", "source_is_builtin_volume", "mesh"]);
32
+ function metadata(block, type) {
33
+ const out = new Map();
34
+ for (const m of block.matchAll(/<metadata\s+type="(object|volume)"\s+key="([a-z_0-9]{1,80})"\s+value="([^"]*)"\s*\/>/g)) {
35
+ if (m[1] === type)
36
+ out.set(m[2], decodeXml(m[3]));
37
+ }
38
+ return out;
39
+ }
40
+ function decodeXml(s) {
41
+ return s.replace(/&(amp|lt|gt|quot|apos|#(\d{1,7}));/g, (_, name, code) => {
42
+ if (code)
43
+ return String.fromCodePoint(Math.min(Number(code), 0x10ffff));
44
+ return { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" }[name] ?? "";
45
+ });
46
+ }
47
+ const int = (s, fallback) => {
48
+ const n = Number(s);
49
+ return s !== undefined && /^-?\d{1,9}$/.test(s) ? n : fallback;
50
+ };
51
+ /** Every object in the config, in file order; an object without a usable id is skipped. */
52
+ export function parsePrusaModelConfig(xml) {
53
+ const objects = [];
54
+ for (const o of xml.matchAll(/<object\s+id="(\d{1,9})"[^>]*>([\s\S]*?)<\/object>/g)) {
55
+ if (objects.length >= MAX_OBJECTS)
56
+ break;
57
+ const body = o[2];
58
+ // Object-level metadata sits outside the volumes; strip them first so a volume's keys aren't read as the object's.
59
+ const own = metadata(body.replace(/<volume\b[\s\S]*?<\/volume>/g, ""), "object");
60
+ const volumes = [];
61
+ for (const v of body.matchAll(/<volume\s+firstid="(\d{1,9})"\s+lastid="(\d{1,9})"[^>]*>([\s\S]*?)<\/volume>/g)) {
62
+ if (volumes.length >= MAX_VOLUMES)
63
+ break;
64
+ const meta = metadata(v[3], "volume");
65
+ volumes.push({
66
+ firstTriangle: int(v[1], 0),
67
+ lastTriangle: int(v[2], 0),
68
+ volumeType: meta.get("volume_type") ?? "ModelPart",
69
+ extruder: int(meta.get("extruder"), 0),
70
+ name: meta.get("name") ?? "",
71
+ settings: new Map([...meta].filter(([k]) => !NOT_SETTINGS.has(k))),
72
+ });
73
+ }
74
+ objects.push({
75
+ id: int(o[1], 0),
76
+ name: own.get("name") ?? "",
77
+ extruder: int(own.get("extruder"), 0),
78
+ volumes,
79
+ settings: new Map([...own].filter(([k]) => !NOT_SETTINGS.has(k))),
80
+ });
81
+ }
82
+ return objects;
83
+ }