any2orca 0.5.0 → 0.7.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.
@@ -24,6 +24,7 @@ const PROJECT_STATE_VECTORS = {
24
24
  flush_volumes_matrix: true,
25
25
  filament_load_time: true,
26
26
  filament_unload_time: true,
27
+ filament_z_hop_types: true,
27
28
  };
28
29
  /**
29
30
  * Whether the key is written as a list: a filament or machine setting Snapmaker Orca keeps per filament or per
@@ -130,6 +131,7 @@ const TRANSFORMS = {
130
131
  warnings.push(` note: ${fromExtruders} filament color(s) taken from the printer's extruder colors, which are what PrusaSlicer shows for this project.`);
131
132
  return out;
132
133
  },
134
+ filamentZHopTypes: ({ ini, key }) => entries(ini, key, "filament_z_hop_types").map((entry) => (entry === "nil" ? "nil" : entry === "1" ? "Slope Lift" : "Normal Lift")),
133
135
  filamentType: ({ ini }) => entries(ini, "filament_type", "filament_type").map((type) => ({ PET: "PETG", NYLON: "PA" })[type] ?? type),
134
136
  firstLayerHeight: ({ ini, value }) => {
135
137
  const layer = ini.settings.get("layer_height");
@@ -137,7 +139,8 @@ const TRANSFORMS = {
137
139
  return resolved === null ? null : [resolved];
138
140
  },
139
141
  gapFillTarget: ({ value }) => [value === "0" ? "nowhere" : "everywhere"],
140
- infillCombination: ({ value }) => [num(value) > 1 ? "1" : "0"],
142
+ infillCombination: ({ ini }) => [ini.settings.get("automatic_infill_combination") === "1" || num(ini.settings.get("infill_every_layers") ?? "1") > 1 ? "1" : "0"],
143
+ invertBool: ({ value }) => [value === "1" ? "0" : "1"],
141
144
  ironingType: ({ ini, value }) => [ini.settings.get("ironing") === "1" ? value : "no ironing"],
142
145
  onlyOneWallTop: ({ value }) => [value === "none" ? "0" : "1"],
143
146
  percentComplement: ({ ini, key }) => entries(ini, key, "filament_shrink").map((entry) => `${fmt(100 - num(entry))}%`),
@@ -153,6 +156,8 @@ const TRANSFORMS = {
153
156
  return null;
154
157
  },
155
158
  printSequence: ({ value }) => [value === "1" ? "by object" : "by layer"],
159
+ // PrusaSlicer's "a solid layer every N layers" is Orca's "insert solid layers: N"; 0 is off, so nothing to carry.
160
+ solidEveryLayers: ({ value }) => (num(value) > 0 ? [String(Math.trunc(num(value)))] : null),
156
161
  supportBottomZ: ({ ini, value }) => [value === "0" ? (ini.settings.get("support_material_contact_distance") ?? value) : value],
157
162
  supportThreshold: ({ key, value, dropped }) => {
158
163
  if (value !== "0")
@@ -174,6 +179,8 @@ const TRANSFORMS = {
174
179
  }
175
180
  return [fmt((num(value) / 100) * width)];
176
181
  },
182
+ // Only the clockwise choice is a change from Orca's automatic direction.
183
+ wallDirection: ({ value }) => (value === "1" ? ["cw"] : null),
177
184
  wallSequence: ({ value }) => [value === "1" ? "outer wall/inner wall" : "inner wall/outer wall"],
178
185
  zHopTypes: ({ ini, key }) => entries(ini, key, "z_hop_types").map((entry) => (entry === "1" ? "Slope Lift" : "Normal Lift")),
179
186
  };
@@ -233,9 +240,11 @@ export function convertObjectOverrides(ini, overrides) {
233
240
  }
234
241
  export function convertPrusaSettings(ini) {
235
242
  const settings = {};
243
+ const targets = new Map();
236
244
  const dropped = [];
237
245
  const unknown = [];
238
246
  const warnings = [];
247
+ let current = "";
239
248
  const write = (target, list) => {
240
249
  // Every entry `nil` is PrusaSlicer's "not set" (a filament override left to the printer): nothing to carry.
241
250
  if (list.every((entry) => entry === "nil"))
@@ -248,10 +257,13 @@ export function convertPrusaSettings(ini) {
248
257
  return;
249
258
  }
250
259
  const value = shaped(target, list);
251
- if (value !== null)
260
+ if (value !== null) {
252
261
  settings[target] = value;
262
+ targets.set(current, [...(targets.get(current) ?? []), target]);
263
+ }
253
264
  };
254
265
  for (const [key, value] of ini.settings) {
266
+ current = key;
255
267
  const rule = PRUSA_KEY_MAP[key];
256
268
  if (!rule) {
257
269
  unknown.push(key);
@@ -306,12 +318,13 @@ export function convertPrusaSettings(ini) {
306
318
  if (!Array.isArray(settings.flush_volumes_matrix))
307
319
  settings.flush_volumes_matrix = Array.from({ length: filamentCount * filamentCount }, () => "0");
308
320
  settings.flush_volumes_vector = Array.from({ length: filamentCount * 2 }, () => "140");
309
- // Policy: everything mapped counts as changed by the creator. The print entry lists every non-filament key; the
310
- // filament entries (one per filament) and the printer entry stay empty, as the pipeline overlays filament values
311
- // whole and never takes machine values.
321
+ // Policy: every mapped print setting counts as changed by the creator, so the print entry lists them all. The
322
+ // filament entries (one per filament) and the printer entry stay empty: the pipeline overlays filament values whole,
323
+ // and the printer's settings (retraction, purge moves, limits) are the U1's own, as they are for a Bambu-family
324
+ // project, whose list never names them either. Snapmaker Orca itself takes them from its printer preset on load.
312
325
  const printKeys = Object.keys(settings)
313
- .filter((k) => SETTINGS_CATALOG[k]?.group !== "filament" && k !== "version" && !k.startsWith("flush_volumes_"))
326
+ .filter((k) => SETTINGS_CATALOG[k]?.group === "print")
314
327
  .sort();
315
328
  settings.different_settings_to_system = [printKeys.join(";"), ...Array.from({ length: filamentCount }, () => ""), ""];
316
- return { settings, dropped, unknown, warnings };
329
+ return { settings, targets, dropped, unknown, warnings };
317
330
  }
@@ -27,7 +27,7 @@
27
27
  * - `handled`: read by another part of the reader (the color changes, the
28
28
  * filament colors), not by the settings map.
29
29
  */
30
- export type PrusaTransform = "arcFitting" | "filamentColour" | "filamentType" | "firstLayerHeight" | "gapFillTarget" | "infillCombination" | "ironingType" | "onlyOneWallTop" | "percentComplement" | "percentOfFirstLayerSpeed" | "percentOfInfillSpeed" | "percentOfPerimeterSpeed" | "percentOfSolidInfillSpeed" | "percentOfSupportSpeed" | "percentOnly" | "printSequence" | "supportBottomZ" | "supportThreshold" | "supportType" | "supportXySpacing" | "wallSequence" | "zHopTypes";
30
+ export type PrusaTransform = "arcFitting" | "filamentColour" | "filamentZHopTypes" | "filamentType" | "firstLayerHeight" | "gapFillTarget" | "infillCombination" | "invertBool" | "ironingType" | "onlyOneWallTop" | "percentComplement" | "percentOfFirstLayerSpeed" | "percentOfInfillSpeed" | "percentOfPerimeterSpeed" | "percentOfSolidInfillSpeed" | "percentOfSupportSpeed" | "percentOnly" | "printSequence" | "solidEveryLayers" | "supportBottomZ" | "supportThreshold" | "supportType" | "supportXySpacing" | "wallDirection" | "wallSequence" | "zHopTypes";
31
31
  export type PrusaKeyRule = {
32
32
  readonly kind: "same";
33
33
  } | {
@@ -138,9 +138,10 @@ export const PRUSA_KEY_MAP = Object.freeze({
138
138
  top_fill_pattern: choices("top_surface_pattern", SURFACE_PATTERNS),
139
139
  bottom_fill_pattern: choices("bottom_surface_pattern", SURFACE_PATTERNS),
140
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),
141
+ // Either PrusaSlicer switch (2.9's automatic one, or combining every N layers) turns Snapmaker Orca's combination on.
142
+ automatic_infill_combination: transform("infill_combination", "infillCombination"),
143
+ automatic_infill_combination_max_layer_height: rename("infill_combination_max_layer_height"),
144
+ solid_infill_every_layers: transform("extra_solid_infills", "solidEveryLayers"),
144
145
  infill_only_where_needed: drop(NO_COUNTERPART),
145
146
  infill_first: rename("is_infill_first"),
146
147
  infill_overlap: transform("infill_wall_overlap", "percentOnly"),
@@ -229,7 +230,7 @@ export const PRUSA_KEY_MAP = Object.freeze({
229
230
  support_material_interface_pattern: choices("support_interface_pattern", { auto: "auto", rectilinear: "rectilinear", concentric: "concentric" }),
230
231
  support_material_interface_spacing: rename("support_interface_spacing"),
231
232
  support_material_xy_spacing: transform("support_object_xy_distance", "supportXySpacing"),
232
- support_material_synchronize_layers: drop(NO_COUNTERPART),
233
+ support_material_synchronize_layers: transform("independent_support_layer_height", "invertBool"),
233
234
  support_tree_angle: rename("tree_support_branch_angle"),
234
235
  support_tree_angle_slow: rename("tree_support_angle_slow"),
235
236
  support_tree_branch_diameter: rename("tree_support_branch_diameter"),
@@ -284,7 +285,7 @@ export const PRUSA_KEY_MAP = Object.freeze({
284
285
  notes: same,
285
286
  gcode_substitutions: drop("PrusaSlicer's G-code substitutions"),
286
287
  arc_fitting: transform("enable_arc_fitting", "arcFitting"),
287
- prefer_clockwise_movements: drop(NO_COUNTERPART),
288
+ prefer_clockwise_movements: transform("wall_direction", "wallDirection"),
288
289
  print_settings_id: same,
289
290
  inherits_cummulative: machine,
290
291
  compatible_printers_condition_cummulative: machine,
@@ -326,7 +327,7 @@ export const PRUSA_KEY_MAP = Object.freeze({
326
327
  chamber_minimal_temperature: drop(NO_COUNTERPART),
327
328
  idle_temperature: same,
328
329
  cooling: rename("slow_down_for_layer_cooling"),
329
- fan_always_on: drop("Snapmaker Orca's minimum fan speed applies throughout"),
330
+ fan_always_on: rename("reduce_fan_stop_start_freq"),
330
331
  min_fan_speed: rename("fan_min_speed"),
331
332
  max_fan_speed: rename("fan_max_speed"),
332
333
  bridge_fan_speed: rename("overhang_fan_speed"),
@@ -356,7 +357,7 @@ export const PRUSA_KEY_MAP = Object.freeze({
356
357
  filament_retract_length_toolchange: same,
357
358
  filament_retract_restart_extra_toolchange: same,
358
359
  filament_seam_gap_distance: drop(NO_COUNTERPART),
359
- filament_travel_ramping_lift: drop(NO_COUNTERPART),
360
+ filament_travel_ramping_lift: transform("filament_z_hop_types", "filamentZHopTypes"),
360
361
  filament_travel_slope: drop(NO_COUNTERPART),
361
362
  filament_travel_max_lift: drop(NO_COUNTERPART),
362
363
  filament_travel_lift_before_obstacle: drop(NO_COUNTERPART),
@@ -389,10 +390,11 @@ export const PRUSA_KEY_MAP = Object.freeze({
389
390
  printer_notes: same,
390
391
  printer_technology: same,
391
392
  physical_printer_settings_id: machine,
392
- bed_shape: machine,
393
+ // The printer's own, never transferred (the pipeline blocks them), but the inspection shows the source bed from them.
394
+ bed_shape: rename("printable_area"),
393
395
  bed_custom_model: machine,
394
396
  bed_custom_texture: machine,
395
- max_print_height: machine,
397
+ max_print_height: rename("printable_height"),
396
398
  max_layer_height: machine,
397
399
  min_layer_height: machine,
398
400
  duplicate_distance: machine,
@@ -46,5 +46,9 @@ export interface PrusaObject {
46
46
  /** Per-object settings besides the ones above, as written (PrusaSlicer keys). */
47
47
  settings: Map<string, string>;
48
48
  }
49
- /** Every object in the config, in file order; an object without a usable id is skipped. */
49
+ /**
50
+ * Every object in the config, in file order; an object without a usable id is skipped. The blocks are found in one
51
+ * pass (xmlBlocks): a lazy `<object>[\s\S]*?</object>` pattern rescans the rest of the file for every opener without a
52
+ * closer, which a crafted file turns into minutes.
53
+ */
50
54
  export declare function parsePrusaModelConfig(xml: string): PrusaObject[];
@@ -25,6 +25,7 @@
25
25
  * that shape is enough; it's untrusted input all the same, so everything is
26
26
  * bounded and anything unexpected is skipped, never trusted.
27
27
  */
28
+ import { xmlBlocks } from "../../archive/xmlBlocks.js";
28
29
  const MAX_OBJECTS = 10_000;
29
30
  const MAX_VOLUMES = 10_000;
30
31
  /** Metadata keys that aren't settings: identity and the volume's own bookkeeping. */
@@ -48,31 +49,44 @@ const int = (s, fallback) => {
48
49
  const n = Number(s);
49
50
  return s !== undefined && /^-?\d{1,9}$/.test(s) ? n : fallback;
50
51
  };
51
- /** Every object in the config, in file order; an object without a usable id is skipped. */
52
+ /**
53
+ * Every object in the config, in file order; an object without a usable id is skipped. The blocks are found in one
54
+ * pass (xmlBlocks): a lazy `<object>[\s\S]*?</object>` pattern rescans the rest of the file for every opener without a
55
+ * closer, which a crafted file turns into minutes.
56
+ */
52
57
  export function parsePrusaModelConfig(xml) {
53
58
  const objects = [];
54
- for (const o of xml.matchAll(/<object\s+id="(\d{1,9})"[^>]*>([\s\S]*?)<\/object>/g)) {
59
+ for (const { attrs, body } of xmlBlocks(xml, "object")) {
55
60
  if (objects.length >= MAX_OBJECTS)
56
61
  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");
62
+ const id = /^\s*id="(\d{1,9})"/.exec(` ${attrs}`)?.[1] ?? /\bid="(\d{1,9})"/.exec(attrs)?.[1];
63
+ if (!id)
64
+ continue;
65
+ // Object-level metadata sits outside the volumes; the volume blocks are cut out first so a volume's keys aren't read
66
+ // as the object's.
60
67
  const volumes = [];
61
- for (const v of body.matchAll(/<volume\s+firstid="(\d{1,9})"\s+lastid="(\d{1,9})"[^>]*>([\s\S]*?)<\/volume>/g)) {
68
+ let ownText = body;
69
+ for (const v of xmlBlocks(body, "volume")) {
62
70
  if (volumes.length >= MAX_VOLUMES)
63
71
  break;
64
- const meta = metadata(v[3], "volume");
72
+ const first = /\bfirstid="(\d{1,9})"/.exec(v.attrs)?.[1];
73
+ const last = /\blastid="(\d{1,9})"/.exec(v.attrs)?.[1];
74
+ if (first === undefined || last === undefined)
75
+ continue;
76
+ ownText = ownText.replace(v.body, "");
77
+ const meta = metadata(v.body, "volume");
65
78
  volumes.push({
66
- firstTriangle: int(v[1], 0),
67
- lastTriangle: int(v[2], 0),
79
+ firstTriangle: int(first, 0),
80
+ lastTriangle: int(last, 0),
68
81
  volumeType: meta.get("volume_type") ?? "ModelPart",
69
82
  extruder: int(meta.get("extruder"), 0),
70
83
  name: meta.get("name") ?? "",
71
84
  settings: new Map([...meta].filter(([k]) => !NOT_SETTINGS.has(k))),
72
85
  });
73
86
  }
87
+ const own = metadata(ownText, "object");
74
88
  objects.push({
75
- id: int(o[1], 0),
89
+ id: int(id, 0),
76
90
  name: own.get("name") ?? "",
77
91
  extruder: int(own.get("extruder"), 0),
78
92
  volumes,
@@ -0,0 +1,46 @@
1
+ import type { ProfileCatalog } from "../../profiles.js";
2
+ import type { ProjectSettings } from "../../schema.js";
3
+ import type { PrusaProjectInfo } from "../reader.js";
4
+ import type { PrusaBundle } from "./bundle.js";
5
+ export interface PolicyBResult {
6
+ /** The bundle's name for the project's print preset, once resolved. */
7
+ presetName: string;
8
+ /** PrusaSlicer keys whose project value differs from the preset's (or that the preset lacks). */
9
+ changedKeys: string[];
10
+ /** Keys compared: the project's print keys that had a rule and a preset value. */
11
+ compared: number;
12
+ }
13
+ /**
14
+ * The project's changed print keys against the vendor preset, or null when the
15
+ * bundle doesn't have the preset.
16
+ *
17
+ * @param settings the project's settings, PrusaSlicer keys and values as the INI has them
18
+ * @param printKeys the project keys that are print settings (the key map's print-group targets), to compare
19
+ */
20
+ export declare function changedPrintKeys(bundle: PrusaBundle, recordedPresetName: string, settings: ReadonlyMap<string, string>, printKeys: ReadonlySet<string>): PolicyBResult | null;
21
+ type BundleEntry = ReturnType<ProfileCatalog["prusaBundles"]>[number];
22
+ /**
23
+ * The bundles to try for a project, best first: per vendor, the newest whose
24
+ * PrusaSlicer release is at or below the one that saved the project (the
25
+ * presets as that release shipped them), then the newest of all as a fallback
26
+ * for a project from a release older than any pinned. A project of unknown
27
+ * version gets the newest.
28
+ */
29
+ export declare function bundlesForVersion(bundles: readonly BundleEntry[], version: string | null): BundleEntry[];
30
+ export interface PolicyBApplied {
31
+ /** The project settings with the changed list rewritten to the keys the creator changed. */
32
+ projectSettings: ProjectSettings;
33
+ notes: string[];
34
+ }
35
+ /**
36
+ * Applies policy B to a PrusaSlicer project's converted settings: finds the
37
+ * project's print preset in the catalog's vendor bundles, and rewrites the
38
+ * changed list (`different_settings_to_system`, print entry) to the Snapmaker
39
+ * Orca keys the creator's changed settings map to. Returns null, with the
40
+ * reason as a note, when no bundle has the preset: the list then stays as
41
+ * the reader wrote it (every mapped print setting), which is policy A.
42
+ */
43
+ export declare function applyPolicyB(prusa: PrusaProjectInfo, catalog: ProfileCatalog, projectSettings: ProjectSettings): Promise<PolicyBApplied | null>;
44
+ /** The note for a project whose print preset no bundle has, so every mapped print setting is carried. */
45
+ export declare function policyBFallbackNote(prusa: PrusaProjectInfo, catalog: ProfileCatalog): string;
46
+ export {};
@@ -0,0 +1,142 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Policy B for a PrusaSlicer project: carry only the print settings the
4
+ * creator changed from the vendor's preset, as a Bambu Studio family project's
5
+ * own list of changed settings does. The project's print preset is resolved
6
+ * from the vendor bundle, every key the project has is compared with the
7
+ * preset's value (in PrusaSlicer's own value forms), and the keys that differ,
8
+ * mapped to Snapmaker Orca's, become the changed list the pipeline's gate
9
+ * reads. Keys the preset doesn't have count as changed: transfer is the safe
10
+ * side. Filament values are carried whole, as for every source.
11
+ */
12
+ import { SETTINGS_CATALOG } from "../../diff/settingsCatalog.js";
13
+ import { lookupPrintPresetName, resolvePrintPreset } from "./bundle.js";
14
+ /** PrusaSlicer keys that identify or describe a preset, never a print setting a creator "changes". */
15
+ const NOT_COMPARED = new Set(["print_settings_id", "inherits", "compatible_printers", "compatible_printers_condition", "renamed_from", "alias", "notes"]);
16
+ const NUMBER = /^-?\d+(\.\d+)?%?$/;
17
+ /** One value in PrusaSlicer's INI, normalized for a comparison: numbers by value, lists entry by entry. */
18
+ function normalize(value) {
19
+ const trimmed = value.trim();
20
+ if (NUMBER.test(trimmed)) {
21
+ const percent = trimmed.endsWith("%");
22
+ return `${Number.parseFloat(trimmed)}${percent ? "%" : ""}`;
23
+ }
24
+ if (trimmed.includes(",") || trimmed.includes(";")) {
25
+ return trimmed
26
+ .split(/[,;]/)
27
+ .map((entry) => normalize(entry))
28
+ .join(",");
29
+ }
30
+ return trimmed.replace(/^"(.*)"$/s, "$1").replace(/\r\n/g, "\n");
31
+ }
32
+ /**
33
+ * The project's changed print keys against the vendor preset, or null when the
34
+ * bundle doesn't have the preset.
35
+ *
36
+ * @param settings the project's settings, PrusaSlicer keys and values as the INI has them
37
+ * @param printKeys the project keys that are print settings (the key map's print-group targets), to compare
38
+ */
39
+ export function changedPrintKeys(bundle, recordedPresetName, settings, printKeys) {
40
+ const presetName = lookupPrintPresetName(bundle, recordedPresetName);
41
+ if (!presetName)
42
+ return null;
43
+ const preset = resolvePrintPreset(bundle, presetName);
44
+ if (!preset)
45
+ return null;
46
+ const changedKeys = [];
47
+ let compared = 0;
48
+ for (const [key, value] of settings) {
49
+ if (!printKeys.has(key) || NOT_COMPARED.has(key))
50
+ continue;
51
+ // A key no preset in the chain sets has PrusaSlicer's built-in default in a project; that's not a change either.
52
+ const presetValue = preset[key] ?? bundle.defaults[key];
53
+ if (presetValue === undefined) {
54
+ changedKeys.push(key);
55
+ continue;
56
+ }
57
+ compared++;
58
+ if (normalize(value) !== normalize(presetValue))
59
+ changedKeys.push(key);
60
+ }
61
+ return { presetName, changedKeys: changedKeys.sort(), compared };
62
+ }
63
+ const versionParts = (v) => v.split(".").map(Number);
64
+ const compareVersions = (a, b) => {
65
+ const [x, y] = [versionParts(a), versionParts(b)];
66
+ return x[0] - y[0] || x[1] - y[1] || x[2] - y[2];
67
+ };
68
+ /**
69
+ * The bundles to try for a project, best first: per vendor, the newest whose
70
+ * PrusaSlicer release is at or below the one that saved the project (the
71
+ * presets as that release shipped them), then the newest of all as a fallback
72
+ * for a project from a release older than any pinned. A project of unknown
73
+ * version gets the newest.
74
+ */
75
+ export function bundlesForVersion(bundles, version) {
76
+ const byVendor = new Map();
77
+ for (const b of bundles)
78
+ byVendor.set(b.vendor, [...(byVendor.get(b.vendor) ?? []), b]);
79
+ const ordered = [];
80
+ for (const list of byVendor.values()) {
81
+ const newestFirst = [...list].sort((a, b) => compareVersions(b.slicerVersion, a.slicerVersion));
82
+ const matching = version ? newestFirst.find((b) => compareVersions(b.slicerVersion, version) <= 0) : undefined;
83
+ if (matching)
84
+ ordered.push(matching);
85
+ if (newestFirst[0] && newestFirst[0] !== matching)
86
+ ordered.push(newestFirst[0]);
87
+ }
88
+ return ordered;
89
+ }
90
+ /**
91
+ * Applies policy B to a PrusaSlicer project's converted settings: finds the
92
+ * project's print preset in the catalog's vendor bundles, and rewrites the
93
+ * changed list (`different_settings_to_system`, print entry) to the Snapmaker
94
+ * Orca keys the creator's changed settings map to. Returns null, with the
95
+ * reason as a note, when no bundle has the preset: the list then stays as
96
+ * the reader wrote it (every mapped print setting), which is policy A.
97
+ */
98
+ export async function applyPolicyB(prusa, catalog, projectSettings) {
99
+ const bundles = catalog.prusaBundles();
100
+ if (bundles.length === 0)
101
+ return null;
102
+ // The PrusaSlicer keys that are print settings: those whose Snapmaker Orca keys are in the print group.
103
+ const printKeys = new Set([...prusa.targets].filter(([, targets]) => targets.some((t) => SETTINGS_CATALOG[t]?.group === "print")).map(([key]) => key));
104
+ for (const entry of bundlesForVersion(bundles, prusa.version)) {
105
+ // A bundle that can't be read (a site that copied an older data folder, say) is no reason to fail the conversion:
106
+ // the next bundle is tried, and the fallback carries every mapped print setting, with the note saying so.
107
+ let bundle;
108
+ try {
109
+ bundle = await catalog.prusaBundle(entry.vendor, entry.slicerVersion);
110
+ }
111
+ catch {
112
+ bundle = null;
113
+ }
114
+ if (!bundle)
115
+ continue;
116
+ const result = changedPrintKeys(bundle, prusa.presets.print, prusa.settings, printKeys);
117
+ if (!result)
118
+ continue;
119
+ const changedTargets = new Set();
120
+ for (const key of result.changedKeys)
121
+ for (const target of prusa.targets.get(key) ?? [])
122
+ if (SETTINGS_CATALOG[target]?.group === "print")
123
+ changedTargets.add(target);
124
+ const list = projectSettings.different_settings_to_system;
125
+ const rest = Array.isArray(list) ? list.slice(1) : [];
126
+ return {
127
+ projectSettings: { ...projectSettings, different_settings_to_system: [[...changedTargets].sort().join(";"), ...rest] },
128
+ notes: [
129
+ ` note: print settings compared with PrusaSlicer's "${result.presetName}" (${entry.name}'s presets of PrusaSlicer ${entry.slicerVersion}): ${result.changedKeys.length} of ${result.compared + result.changedKeys.length} differ from the preset, and only those are carried; Snapmaker's stock stands for the rest.`,
130
+ ],
131
+ };
132
+ }
133
+ return null;
134
+ }
135
+ /** The note for a project whose print preset no bundle has, so every mapped print setting is carried. */
136
+ export function policyBFallbackNote(prusa, catalog) {
137
+ const bundles = catalog.prusaBundles();
138
+ if (bundles.length === 0)
139
+ return " note: this profile catalog has no PrusaSlicer vendor presets, so every mapped print setting is carried as the creator's.";
140
+ const vendors = [...new Set(bundles.map((b) => b.name))].join(" or ");
141
+ return ` note: print preset "${prusa.presets.print.slice(0, 80)}" isn't in ${vendors}'s presets (a user preset, or one this catalog doesn't know), so every mapped print setting is carried as the creator's.`;
142
+ }
@@ -55,5 +55,5 @@ export declare function partsOf(object: PrusaObject, components: ReadonlyMap<num
55
55
  * Bambu's `model_settings.config`: each object with its name, filament and settings, its parts, and one plate holding
56
56
  * every instance.
57
57
  */
58
- export declare function buildModelSettings(ini: PrusaIni, objects: readonly PrusaObject[], instanceCounts: ReadonlyMap<number, number>, parts: (object: PrusaObject) => ModelPart[]): string;
58
+ export declare function buildModelSettings(ini: PrusaIni, objects: readonly PrusaObject[], instanceCounts: ReadonlyMap<number, number>, parts: (object: PrusaObject) => ModelPart[], plateOf?: (objectId: number) => number): string;
59
59
  export declare const prusaReader: SourceReader;