any2orca 0.10.0 → 0.12.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.
Files changed (49) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +2 -2
  3. package/dist/cli/commands/convert.d.ts +2 -1
  4. package/dist/cli/commands/convert.js +1 -0
  5. package/dist/cli/commands/nozzle.d.ts +9 -0
  6. package/dist/cli/commands/nozzle.js +38 -0
  7. package/dist/cli/config.d.ts +4 -0
  8. package/dist/cli/config.js +5 -0
  9. package/dist/cli/main.js +41 -0
  10. package/dist/cli/surface.d.ts +11 -0
  11. package/dist/cli/surface.js +3 -0
  12. package/dist/diff/diffSettings.js +14 -5
  13. package/dist/engine/applyFilamentComplianceMode.d.ts +3 -1
  14. package/dist/engine/applyFilamentComplianceMode.js +5 -1
  15. package/dist/engine/applyFilamentFlowVariants.d.ts +2 -2
  16. package/dist/engine/applyFilamentFlowVariants.js +4 -4
  17. package/dist/engine/applyFilamentPresets.d.ts +50 -5
  18. package/dist/engine/applyFilamentPresets.js +162 -39
  19. package/dist/engine/buildProjectSettings.js +4 -2
  20. package/dist/engine/detectNozzleDiameter.d.ts +28 -0
  21. package/dist/engine/detectNozzleDiameter.js +44 -0
  22. package/dist/engine/detectVariantIndex.d.ts +13 -0
  23. package/dist/engine/detectVariantIndex.js +25 -13
  24. package/dist/engine/extractFilamentSlots.js +7 -1
  25. package/dist/engine/filamentVariantLayout.d.ts +31 -3
  26. package/dist/engine/filamentVariantLayout.js +54 -2
  27. package/dist/engine/fillFilamentSlots.js +2 -1
  28. package/dist/engine/padFilamentsToToolheads.d.ts +20 -0
  29. package/dist/engine/padFilamentsToToolheads.js +82 -0
  30. package/dist/engine/policy.d.ts +17 -0
  31. package/dist/engine/policy.js +45 -0
  32. package/dist/engine/runConvertPipeline.d.ts +15 -0
  33. package/dist/engine/runConvertPipeline.js +136 -9
  34. package/dist/engine/setFilamentDiameter.d.ts +13 -0
  35. package/dist/engine/setFilamentDiameter.js +30 -0
  36. package/dist/explain/whatChanged.js +2 -1
  37. package/dist/index.d.ts +3 -3
  38. package/dist/index.js +1 -1
  39. package/dist/inspect.d.ts +8 -2
  40. package/dist/inspect.js +2 -1
  41. package/dist/profiles.d.ts +9 -0
  42. package/dist/profiles.js +10 -0
  43. package/dist/project.d.ts +42 -8
  44. package/dist/project.js +71 -19
  45. package/dist/stamp.d.ts +12 -0
  46. package/dist/stamp.js +7 -0
  47. package/dist/version.js +1 -1
  48. package/dist/workerProtocol.d.ts +2 -0
  49. package/package.json +3 -3
@@ -0,0 +1,82 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
3
+ /**
4
+ * The colors Snapmaker Orca gives the filaments it adds, in order (Plater.cpp, get_next_color_for_filament). The app
5
+ * keeps one counter for the whole session, so these are the colors a freshly started app gives its first ones.
6
+ */
7
+ export const NEW_FILAMENT_COLORS = [
8
+ "#00C1AE", "#F4E2C1", "#ED1C24", "#00FF7F", "#F26722", "#FFEB31", "#7841CE", "#115877",
9
+ "#ED1E79", "#2EBDEF", "#345B2F", "#800080", "#FA8173", "#800000", "#F7B763", "#A4C41E",
10
+ ];
11
+ /** Per-filament settings the settings catalog doesn't list as filament settings. */
12
+ const PROJECT_FILAMENT_KEYS = new Set(["filament_settings_id", "filament_ids", "filament_flow_step_size", "filament_volume_type"]);
13
+ /** Lists with the print's entry first, one entry per filament, and the printer's last. */
14
+ const FRAMED_KEYS = ["different_settings_to_system", "inherits_group"];
15
+ /** A color as "RRGGBB", so "#00c1ae" and "#00C1AEFF" compare equal. */
16
+ const colorKey = (value) => {
17
+ const hex = typeof value === "string" ? value.trim().replace(/^#/, "").toUpperCase() : "";
18
+ return hex.length === 8 ? hex.slice(0, 6) : hex;
19
+ };
20
+ const number = (value) => {
21
+ const n = Number(value);
22
+ return Number.isFinite(n) ? n : 0;
23
+ };
24
+ /**
25
+ * Pads a project with fewer filaments than the printer has toolheads to one filament per toolhead, as Snapmaker Orca
26
+ * does when a project is switched to a printer with several (Tab.cpp, "sync filament num if it's a multi tool
27
+ * printer"): each added filament is a copy of the last one, its preset, parent and settings included, in the next of
28
+ * the app's new-filament colors the project doesn't use. No object uses the copies, and the project's own filaments
29
+ * stay as they are. A file with fewer is set up for every toolhead anyway when the app opens it, and then checked
30
+ * against its own shorter lists: the app lists a nameless preset as customized and marks a one-filament project's
31
+ * filament modified. Printers with more toolheads than the palette has colors are left alone.
32
+ *
33
+ * @param filamentKeys the profile's filament settings (its filament template), which the converter reads per filament
34
+ * when it converts a file again, besides those the settings catalog lists as filament settings.
35
+ * @returns how many filaments were added.
36
+ */
37
+ export function padFilamentsToToolheads(settings, slotCount, toolheads, filamentKeys = new Set()) {
38
+ const added = toolheads - slotCount;
39
+ if (slotCount < 1 || added < 1 || toolheads > NEW_FILAMENT_COLORS.length)
40
+ return 0;
41
+ const isPerFilament = (key) => filamentKeys.has(key) || PROJECT_FILAMENT_KEYS.has(key) || (Object.hasOwn(SETTINGS_CATALOG, key) && SETTINGS_CATALOG[key].group === "filament");
42
+ for (const [key, value] of Object.entries(settings)) {
43
+ if (!Array.isArray(value) || !isPerFilament(key))
44
+ continue;
45
+ // One value per filament, or two (standard, high flow).
46
+ const per = value.length === slotCount ? 1 : value.length === slotCount * 2 ? 2 : 0;
47
+ if (per === 0)
48
+ continue;
49
+ const last = value.slice(-per);
50
+ settings[key] = [...value, ...Array.from({ length: added }, () => last).flat()];
51
+ }
52
+ for (const key of FRAMED_KEYS) {
53
+ const value = settings[key];
54
+ if (!Array.isArray(value) || value.length !== slotCount + 2)
55
+ continue;
56
+ settings[key] = [...value.slice(0, -1), ...Array.from({ length: added }, () => value[slotCount]), value[value.length - 1]];
57
+ }
58
+ const own = settings.filament_colour;
59
+ if (Array.isArray(own) && own.length === toolheads) {
60
+ const used = new Set(own.slice(0, slotCount).map(colorKey));
61
+ settings.filament_colour = [...own.slice(0, slotCount), ...NEW_FILAMENT_COLORS.filter((color) => !used.has(colorKey(color))).slice(0, added)];
62
+ }
63
+ // The app sizes the flush volumes the same way: each added filament takes the first one's two values, and each new
64
+ // pair of filaments the sum of the unloading and loading volumes (PresetBundle.cpp, update_multi_material_filament_presets).
65
+ const vector = settings.flush_volumes_vector;
66
+ const matrix = settings.flush_volumes_matrix;
67
+ if (Array.isArray(vector) && vector.length === slotCount * 2 && Array.isArray(matrix) && matrix.length === slotCount * slotCount) {
68
+ const volumes = [...vector, ...Array.from({ length: added }, () => [vector[0], vector[1]]).flat()].map(String);
69
+ const flush = [];
70
+ for (let row = 0; row < toolheads; row++) {
71
+ for (let col = 0; col < toolheads; col++) {
72
+ if (row < slotCount && col < slotCount)
73
+ flush.push(String(matrix[row * slotCount + col]));
74
+ else
75
+ flush.push(row === col ? "0" : String(Math.round((number(volumes[row * 2]) + number(volumes[col * 2 + 1])) * 1e6) / 1e6));
76
+ }
77
+ }
78
+ settings.flush_volumes_vector = volumes;
79
+ settings.flush_volumes_matrix = flush;
80
+ }
81
+ return added;
82
+ }
@@ -18,5 +18,22 @@ export declare const MACHINE_SETTINGS_KEYS: readonly string[];
18
18
  * profile's value. Snapmaker's U1 filaments carry only a comment there.
19
19
  */
20
20
  export declare function isGcodeKey(key: string): boolean;
21
+ /**
22
+ * The filament settings that describe the spool rather than the printer: what the filament is, what it costs,
23
+ * and the temperatures it wants. They stay the creator's when a filament tuned for another nozzle size takes the
24
+ * U1 preset's calibration (flow, max volumetric speed, pressure advance, retraction, cooling and the rest), because
25
+ * nothing about them changes with the nozzle. Bambu's own per-size filament presets never override any of these.
26
+ */
27
+ export declare const SPOOL_KEYS: readonly string[];
28
+ /** A filament setting that describes the spool (see {@link SPOOL_KEYS}); every bed temperature counts, whatever the plate. */
29
+ export declare function isSpoolKey(key: string): boolean;
21
30
  /** Filament keys that always keep the U1 profile's value, besides every G-code key (see {@link isGcodeKey}). */
22
31
  export declare const FILAMENT_KEY_BLOCKLIST: readonly string[];
32
+ /**
33
+ * Printer settings named in the printer's entry of `different_settings_to_system`, so Snapmaker Orca's app keeps
34
+ * the file's value: it resets every printer setting the entry doesn't name to the installed printer preset's, and
35
+ * that preset can change without a release (Snapmaker updates its profiles through the app). `nozzle_type`: the
36
+ * file records the U1's stock stainless 0.4 and the hardened 0.6, or hardened nozzles when the user says so, where
37
+ * Snapmaker's presets have the 0.4 and 0.6 swapped. A named value equal to the preset's changes nothing.
38
+ */
39
+ export declare const PRINTER_KEYS_KEPT: readonly string[];
@@ -266,6 +266,43 @@ export const MACHINE_SETTINGS_KEYS = [
266
266
  export function isGcodeKey(key) {
267
267
  return key.endsWith("_gcode");
268
268
  }
269
+ /**
270
+ * The filament settings that describe the spool rather than the printer: what the filament is, what it costs,
271
+ * and the temperatures it wants. They stay the creator's when a filament tuned for another nozzle size takes the
272
+ * U1 preset's calibration (flow, max volumetric speed, pressure advance, retraction, cooling and the rest), because
273
+ * nothing about them changes with the nozzle. Bambu's own per-size filament presets never override any of these.
274
+ */
275
+ export const SPOOL_KEYS = [
276
+ "filament_settings_id",
277
+ "filament_ids",
278
+ "filament_vendor",
279
+ "filament_type",
280
+ "filament_colour",
281
+ "default_filament_colour",
282
+ "filament_density",
283
+ "filament_cost",
284
+ "filament_diameter",
285
+ "nozzle_temperature",
286
+ "nozzle_temperature_initial_layer",
287
+ "nozzle_temperature_range_low",
288
+ "nozzle_temperature_range_high",
289
+ "chamber_temperature",
290
+ "activate_chamber_temp_control",
291
+ "temperature_vitrification",
292
+ "idle_temperature",
293
+ "filament_soluble",
294
+ "filament_is_support",
295
+ "filament_shrink",
296
+ "filament_shrinkage_compensation_z",
297
+ "filament_notes",
298
+ "filament_adhesiveness_category",
299
+ "filament_is_high_temperature",
300
+ ];
301
+ const SPOOL_KEY_SET = new Set(SPOOL_KEYS);
302
+ /** A filament setting that describes the spool (see {@link SPOOL_KEYS}); every bed temperature counts, whatever the plate. */
303
+ export function isSpoolKey(key) {
304
+ return SPOOL_KEY_SET.has(key) || /_plate_temp(_initial_layer)?$/.test(key);
305
+ }
269
306
  /** Filament keys that always keep the U1 profile's value, besides every G-code key (see {@link isGcodeKey}). */
270
307
  export const FILAMENT_KEY_BLOCKLIST = [
271
308
  "compatible_printers",
@@ -273,3 +310,11 @@ export const FILAMENT_KEY_BLOCKLIST = [
273
310
  "compatible_prints",
274
311
  "compatible_prints_condition",
275
312
  ];
313
+ /**
314
+ * Printer settings named in the printer's entry of `different_settings_to_system`, so Snapmaker Orca's app keeps
315
+ * the file's value: it resets every printer setting the entry doesn't name to the installed printer preset's, and
316
+ * that preset can change without a release (Snapmaker updates its profiles through the app). `nozzle_type`: the
317
+ * file records the U1's stock stainless 0.4 and the hardened 0.6, or hardened nozzles when the user says so, where
318
+ * Snapmaker's presets have the 0.4 and 0.6 swapped. A named value equal to the preset's changes nothing.
319
+ */
320
+ export const PRINTER_KEYS_KEPT = ["nozzle_type"];
@@ -54,10 +54,25 @@ export interface RunConvertPipelineOptions {
54
54
  * already checked by resolveAboveStockChoice. Absent: the defaults.
55
55
  */
56
56
  aboveStock?: ResolvedAboveStockChoice;
57
+ /**
58
+ * The nozzle size the file is for and the sizes the creator's project uses (see matchProfile), for a What changed
59
+ * item when they differ. Absent when the profile was given outright.
60
+ */
61
+ nozzle?: {
62
+ size: string;
63
+ sourceSizes: readonly string[];
64
+ };
65
+ /**
66
+ * The nozzle size the profile is for, e.g. "0.4": a filament the creator tuned for another size takes the U1
67
+ * preset's calibration for its material at this size. Absent: no filament is treated that way.
68
+ */
69
+ targetNozzleDiameter?: string;
57
70
  }
58
71
  export interface RunConvertPipelineResult {
59
72
  response: ConvertResponse;
60
73
  warnings: string[];
74
+ /** Notes to show before every other: a filament the creator's printer took at another diameter. Also in `warnings`. */
75
+ leadWarnings: string[];
61
76
  /** What the conversion changed, grouped by why (see explain/whatChanged.ts). */
62
77
  changes: ReadonlyMap<ChangeReason, ChangeItem[]>;
63
78
  }
@@ -1,6 +1,8 @@
1
1
  import { applyFilamentComplianceMode } from "./applyFilamentComplianceMode.js";
2
2
  import { labelOf } from "../diff/diffSettings.js";
3
- import { listFilamentSettings, writeFilamentPresets } from "./applyFilamentPresets.js";
3
+ import { filamentBases, listFilamentSettings, presetChanges as changedPresetValues, presetSettingsFor, syncEmbeddedPresets, writeBaseGcode, writeFilamentPresets, } from "./applyFilamentPresets.js";
4
+ import { resolveFilamentName } from "./filamentComplianceNames.js";
5
+ import { padFilamentsToToolheads } from "./padFilamentsToToolheads.js";
4
6
  import { EXTRA_PROJECT_LEVEL_FILAMENT_KEYS } from "./constants.js";
5
7
  import { buildFilamentConfigs } from "./buildFilamentConfigs.js";
6
8
  import { clampColorPenetration } from "./clampColorPenetration.js";
@@ -12,12 +14,14 @@ import { ABOVE_STOCK_DEFAULTS, firstNumber, largestNumber } from "./aboveStock.j
12
14
  import { buildProjectSettings } from "./buildProjectSettings.js";
13
15
  import { carrySourceLayerHeight } from "./carrySourceLayerHeight.js";
14
16
  import { computeShifts } from "./computeShifts.js";
17
+ import { sourceNozzleSizes } from "./detectNozzleDiameter.js";
15
18
  import { extractFilamentSlots } from "./extractFilamentSlots.js";
16
19
  import { fillFilamentSlots } from "./fillFilamentSlots.js";
20
+ import { offSizeDiameter, setFilamentDiameter, U1_FILAMENT_DIAMETER } from "./setFilamentDiameter.js";
17
21
  import { remapBrimType } from "./remapBrimType.js";
18
22
  import { resizeFlushVolumes } from "./resizeFlushVolumes.js";
19
23
  import { ChangeTracker, valueText } from "../explain/whatChanged.js";
20
- import { U1_VALUE_KEYS } from "./policy.js";
24
+ import { isGcodeKey, isSpoolKey, U1_VALUE_KEYS } from "./policy.js";
21
25
  const U1_VALUE_KEY_SET = new Set(U1_VALUE_KEYS);
22
26
  function numbers(value) {
23
27
  return (Array.isArray(value) ? value : [value]).map((v) => Number(v)).filter(Number.isFinite);
@@ -67,6 +71,16 @@ export function runConvertPipeline(profile, request, application, options = {})
67
71
  let filamentComplianceUnchanged;
68
72
  let renamedFilaments = [];
69
73
  let appliedPresets = [];
74
+ // A filament the creator's printer took at another diameter (the H3C's 2.85 mm TPU PrintTool): its values are
75
+ // tuned for that filament in that extruder, so they can't go on 1.75 mm filament in a U1 toolhead under the same
76
+ // name. The slot takes a U1 preset for its material (Snapmaker's, else Generic; Generic when that option was
77
+ // chosen) with that preset's settings; its color, material and place stay. Said first among the notes.
78
+ const sourceSlots = slots;
79
+ const offSizeSlots = new Set(slots.flatMap((slot, i) => (offSizeDiameter(slot.filament_diameter ?? filamentKeyArrays?.filament_diameter?.[i]) === null ? [] : [i])));
80
+ const leadWarnings = [];
81
+ // What changed items for those slots, added under the firmware group once the tracker exists.
82
+ const offSizeItems = [];
83
+ const missingPresetsWarning = (missing) => warnings.push(` WARN: the profile catalog has no settings for ${missing.join(", ")}, so only ${missing.length === 1 ? "its name" : "their names"} changed. Update the profile catalog.`);
70
84
  if (request.filamentComplianceMode) {
71
85
  // Preset names exist per nozzle size, so they follow the target printer, not the source's nozzle.
72
86
  const applied = applyFilamentComplianceMode(slots, filamentKeyArrays, request.filamentComplianceMode, printer.filamentNames, printer.id, printer.filamentPresets);
@@ -74,9 +88,8 @@ export function runConvertPipeline(profile, request, application, options = {})
74
88
  filamentKeyArrays = applied.filamentKeyArrays;
75
89
  renamedFilaments = applied.renamed;
76
90
  appliedPresets = applied.presets;
77
- if (applied.missingPresets.length > 0) {
78
- warnings.push(` WARN: the profile catalog has no settings for ${applied.missingPresets.join(", ")}, so only ${applied.missingPresets.length === 1 ? "its name" : "their names"} changed. Update the profile catalog.`);
79
- }
91
+ if (applied.missingPresets.length > 0)
92
+ missingPresetsWarning(applied.missingPresets);
80
93
  if (applied.fellBackToGenericMaterials.length > 0)
81
94
  filamentComplianceFallback = applied.fellBackToGenericMaterials;
82
95
  if (applied.unchangedMaterials.length > 0)
@@ -88,6 +101,90 @@ export function runConvertPipeline(profile, request, application, options = {})
88
101
  warnings.push(" WARN: this profile catalog has no filament preset settings, so only the filament names changed; Snapmaker Orca uses the presets' own settings when it opens the file. Update the profile catalog.");
89
102
  }
90
103
  }
104
+ else if (offSizeSlots.size > 0) {
105
+ const applied = applyFilamentComplianceMode(slots, filamentKeyArrays, "snapmaker", printer.filamentNames, printer.id, printer.filamentPresets, offSizeSlots);
106
+ slots = applied.slots;
107
+ filamentKeyArrays = applied.filamentKeyArrays;
108
+ renamedFilaments = applied.renamed;
109
+ appliedPresets = applied.presets;
110
+ if (applied.missingPresets.length > 0)
111
+ missingPresetsWarning(applied.missingPresets);
112
+ }
113
+ for (const i of [...offSizeSlots].sort((a, b) => a - b)) {
114
+ const source = sourceSlots[i];
115
+ const name = typeof source.filament_settings_id === "string" && source.filament_settings_id ? source.filament_settings_id : "an unnamed filament";
116
+ const type = typeof source.filament_type === "string" && source.filament_type ? source.filament_type : "filament";
117
+ const diameter = offSizeDiameter(source.filament_diameter ?? filamentKeyArrays?.filament_diameter?.[i]);
118
+ const renamedTo = renamedFilaments.find((r) => r.slot === i)?.after ?? (typeof slots[i]?.filament_settings_id === "string" && slots[i].filament_settings_id !== name ? String(slots[i].filament_settings_id) : null);
119
+ const withSettings = appliedPresets.some((a) => a.slot === i);
120
+ const was = `Filament ${i + 1} was ${name} (${diameter} mm) on the creator's printer. The U1 takes ${U1_FILAMENT_DIAMETER} mm filament, so`;
121
+ if (renamedTo) {
122
+ leadWarnings.push(` WARN: ${was} it's set to ${renamedTo}${withSettings ? " with that preset's settings" : ""}. Load ${U1_FILAMENT_DIAMETER} mm ${type}; the creator's filament may print differently from the preset's, so check its settings before printing.`);
123
+ offSizeItems.push({ label: `Filament ${i + 1} set to ${renamedTo}`, before: `${name} (${diameter} mm)`, after: renamedTo, note: `the U1 takes ${U1_FILAMENT_DIAMETER} mm filament; the creator's values were for ${diameter} mm${withSettings ? "; the preset's settings are used" : ""}` });
124
+ }
125
+ else {
126
+ leadWarnings.push(` WARN: ${was} its diameter is set to ${U1_FILAMENT_DIAMETER} mm. No U1 preset fits its material, so its other settings are the creator's, tuned for ${diameter} mm; load ${U1_FILAMENT_DIAMETER} mm ${type} and check them before printing.`);
127
+ }
128
+ }
129
+ // A filament tuned for another nozzle size than the file is for: its flow, max volumetric speed, pressure
130
+ // advance, retraction and cooling describe the creator's extruder, hotend and nozzle, so it takes the U1 preset's
131
+ // calibration for its material at the target size and keeps the creator's spool facts (SPOOL_KEYS). A naming
132
+ // option already gives every filament a whole preset; a 2.85 mm filament already took one above.
133
+ const target = options.targetNozzleDiameter === undefined ? NaN : Number(options.targetNozzleDiameter);
134
+ if (!request.filamentComplianceMode && Number.isFinite(target)) {
135
+ const sizesOf = sourceNozzleSizes(request.projectSettings).filamentSizes;
136
+ const bySize = new Map();
137
+ sourceSlots.forEach((slot, i) => {
138
+ const size = sizesOf[i];
139
+ if (size === null || size === undefined || offSizeSlots.has(i) || Math.abs(Number(size) - target) < 1e-6)
140
+ return;
141
+ const group = bySize.get(size) ?? { slots: [], presets: new Set(), unmatched: [] };
142
+ bySize.set(size, group);
143
+ group.slots.push(i);
144
+ const type = typeof slot.filament_type === "string" ? slot.filament_type : "";
145
+ const name = typeof slot.filament_settings_id === "string" ? slot.filament_settings_id : "";
146
+ const found = printer.filamentNames ? resolveFilamentName(printer.filamentNames, printer.id, type, name, "snapmaker").preset : undefined;
147
+ const values = found ? presetSettingsFor(printer.filamentPresets, found.name) : undefined;
148
+ if (!found || !values) {
149
+ group.unmatched.push(i);
150
+ return;
151
+ }
152
+ const keys = Object.keys(values).filter((k) => !isSpoolKey(k) && !isGcodeKey(k));
153
+ const subset = Object.fromEntries(keys.map((k) => [k, values[k]]));
154
+ const changed = changedPresetValues(subset, (key) => filamentKeyArrays?.[key]?.[i] ?? slot[key]);
155
+ appliedPresets.push({ slot: i, preset: found.name, keys, changed });
156
+ group.presets.add(found.name);
157
+ const shown = changed.slice(0, 3).map((c) => `${labelOf(c.key)} ${c.before} -> ${c.after}`).join(", ");
158
+ offSizeItems.push({
159
+ label: `Filament ${i + 1} calibrated from ${found.name}`,
160
+ before: `${name || "unnamed"} (${size} mm nozzle)`,
161
+ after: found.name,
162
+ note: `tuned for a ${size} mm nozzle; the U1 preset's flow, max volumetric speed, pressure advance, retraction and cooling for ${options.targetNozzleDiameter} mm${shown ? `: ${shown}` : ""}${changed.length > 3 ? ` and ${changed.length - 3} more` : ""}; the creator's temperatures and other filament facts kept`,
163
+ });
164
+ });
165
+ const listed = (nums) => {
166
+ const n = nums.map((i) => String(i + 1));
167
+ return n.length === 1 ? `Filament ${n[0]} was` : `Filaments ${n.slice(0, -1).join(", ")} and ${n[n.length - 1]} were`;
168
+ };
169
+ for (const [size, group] of [...bySize].sort((a, b) => Number(a[0]) - Number(b[0]))) {
170
+ const taken = group.slots.filter((i) => !group.unmatched.includes(i));
171
+ if (taken.length > 0) {
172
+ leadWarnings.push(` WARN: ${listed(taken)} tuned for a ${size} mm nozzle on the creator's printer; converted for your ${options.targetNozzleDiameter} mm nozzles, ${taken.length === 1 ? "it takes" : "they take"} the U1's calibration for ${taken.length === 1 ? "its material" : "their materials"} from ${[...group.presets].join(", ")} (flow, max volumetric speed, pressure advance, retraction, cooling) and ${taken.length === 1 ? "keeps" : "keep"} the creator's temperatures and other filament facts. The colors are unchanged, so a preset of your own can be chosen in Snapmaker Orca.`);
173
+ }
174
+ if (group.unmatched.length > 0) {
175
+ leadWarnings.push(` WARN: ${listed(group.unmatched)} tuned for a ${size} mm nozzle on the creator's printer, and no U1 preset fits ${group.unmatched.length === 1 ? "its" : "their"} material, so the settings are the creator's; check them before printing on your ${options.targetNozzleDiameter} mm nozzles.`);
176
+ }
177
+ }
178
+ }
179
+ warnings.push(...leadWarnings);
180
+ if (offSizeSlots.size > 0 && !request.filamentComplianceMode) {
181
+ for (const a of appliedPresets) {
182
+ if (a.changed.length === 0 || !offSizeSlots.has(a.slot))
183
+ continue;
184
+ const shown = a.changed.slice(0, 3).map((c) => `${labelOf(c.key)} ${c.before} -> ${c.after}`).join(", ");
185
+ offSizeItems.push({ label: `Filament ${a.slot + 1} uses ${a.preset}'s settings`, before: null, after: null, note: `instead of the creator's: ${shown}${a.changed.length > 3 ? ` and ${a.changed.length - 3} more` : ""}` });
186
+ }
187
+ }
91
188
  const { files: filamentFiles } = buildFilamentConfigs(slots, p.filamentShapeConfig, p.filamentKeyBlocklist);
92
189
  // High-flow hotends (request.highFlowHotends): which toolheads have the
93
190
  // Liber hotend, only where the nozzle supports it. The tier's high-flow
@@ -165,6 +262,8 @@ export function runConvertPipeline(profile, request, application, options = {})
165
262
  });
166
263
  }
167
264
  }
265
+ for (const item of offSizeItems)
266
+ tracker.add("firmware", item);
168
267
  if (useStock.size > 0) {
169
268
  tracker.step(mergedSettings, because("yours", "you chose Snapmaker's stock value"), () => {
170
269
  for (const key of useStock)
@@ -181,6 +280,9 @@ export function runConvertPipeline(profile, request, application, options = {})
181
280
  const slotCount = slots.length > 0 ? slots.length : Array.isArray(newSettings.filament_colour) ? newSettings.filament_colour.length : 0;
182
281
  const filamentFromSource = new Set(Object.keys(filamentKeyArrays ?? {}));
183
282
  fillFilamentSlots(newSettings, filamentTemplateKeys, filamentFromSource, slotCount);
283
+ // The U1 takes 1.75 mm filament. A creator's 2.85 mm tool (the H3C's TPU PrintTool) left in the file would make
284
+ // Snapmaker Orca extrude for filament nearly three times thicker.
285
+ tracker.step(newSettings, because("firmware", "the U1 takes 1.75 mm filament"), () => setFilamentDiameter(newSettings, slotCount, warnings, offSizeSlots));
184
286
  // Laying the filament settings out per hotend type isn't a change in meaning; lowering a max volumetric speed is.
185
287
  tracker.step(newSettings, (key, before, after) => {
186
288
  if (key !== "filament_max_volumetric_speed")
@@ -208,6 +310,15 @@ export function runConvertPipeline(profile, request, application, options = {})
208
310
  if (options.carrySourceLayerHeight) {
209
311
  tracker.step(newSettings, because("creator", "no U1 profile has this layer height, so the creator's is kept"), () => carrySourceLayerHeight(newSettings, request.projectSettings, printer.machineSettingsConfig, warnings));
210
312
  }
313
+ if (options.nozzle && options.nozzle.sourceSizes.some((s) => s !== options.nozzle.size)) {
314
+ const sizes = options.nozzle.sourceSizes;
315
+ tracker.add("yours", {
316
+ label: `Converted for your ${options.nozzle.size} mm nozzles`,
317
+ before: sizes.length > 0 ? `${sizes.join(", ")} mm` : null,
318
+ after: `${options.nozzle.size} mm`,
319
+ note: sizes.length > 1 ? "the creator's project mixes nozzle sizes; Snapmaker Orca allows one for all four toolheads" : "the creator's project is set up for another nozzle size",
320
+ });
321
+ }
211
322
  if (highFlowApplies && highFlowSelection) {
212
323
  tracker.step(newSettings, because("yours", "for the toolheads with the Liber High Flow Hotend"), () => applyHighFlowHotends(newSettings, highFlowSelection, highFlowTuning, warnings));
213
324
  }
@@ -226,10 +337,25 @@ export function runConvertPipeline(profile, request, application, options = {})
226
337
  const { shifts, plateOrigins, warnings: shiftWarnings } = computeShifts(request.objects, printer.printableArea, Number.isFinite(bambuClearanceRadius) ? bambuClearanceRadius : null, printer.extruderClearanceRadius, request.plateCount);
227
338
  warnings.push(...shiftWarnings);
228
339
  addShiftItems(tracker, request.objects, shifts);
229
- // Last of the filament steps: the chosen presets' settings, then every filament setting listed, so Snapmaker
230
- // Orca keeps what the file says.
340
+ // Last of the filament steps: the chosen presets' settings, each U1 base preset's G-code, then each filament's
341
+ // changed settings named against the preset Snapmaker Orca resets it to, so it keeps what the file says, and
342
+ // each embedded preset made to match its filament, so the app doesn't mark it modified.
231
343
  writeFilamentPresets(newSettings, filamentFiles, appliedPresets, printer.filamentPresets, slotCount);
232
- listFilamentSettings(newSettings, slotCount);
344
+ const bases = filamentBases(newSettings, slotCount, printer.filamentPresets, printer.filamentNames, printer.id, Boolean(request.filamentComplianceMode));
345
+ writeBaseGcode(newSettings, filamentFiles, bases, slotCount);
346
+ listFilamentSettings(newSettings, bases, request.projectSettings, slotCount);
347
+ syncEmbeddedPresets(newSettings, filamentFiles, bases, slotCount);
348
+ // One filament per toolhead, as Snapmaker Orca sets a project up when it's switched to the U1.
349
+ const addedFilaments = padFilamentsToToolheads(newSettings, slotCount, toolheads, filamentTemplateKeys);
350
+ if (addedFilaments > 0) {
351
+ const first = slotCount + 1;
352
+ tracker.add("firmware", {
353
+ label: addedFilaments === 1 ? `Filament ${first} added as a copy of filament ${slotCount}` : `Filaments ${first} to ${toolheads} added as copies of filament ${slotCount}`,
354
+ before: null,
355
+ after: null,
356
+ note: `Snapmaker Orca gives the U1 one filament per toolhead, as it does when a project is switched to the U1; no object uses ${addedFilaments === 1 ? "it" : "them"}`,
357
+ });
358
+ }
233
359
  const configFiles = { ...filamentFiles };
234
360
  // `warnings` mixes routine per-conversion bookkeeping (e.g. computeShifts'
235
361
  // "true geometric center -> target" line, which fires on every plate
@@ -249,9 +375,10 @@ export function runConvertPipeline(profile, request, application, options = {})
249
375
  ...(filamentComplianceFallback ? { filamentComplianceFallback } : {}),
250
376
  ...(filamentComplianceUnchanged ? { filamentComplianceUnchanged } : {}),
251
377
  ...(appliedPresets.length > 0 ? { filamentPresets: appliedPresets.map((a) => ({ slot: a.slot + 1, preset: a.preset, changed: a.changed })) } : {}),
252
- ...(userFacingWarnings.length > 0 ? { warnings: userFacingWarnings } : {}),
378
+ ...(userFacingWarnings.length > 0 ? { warnings: userFacingWarnings.filter((w) => !leadWarnings.includes(w)) } : {}),
253
379
  },
254
380
  warnings,
381
+ leadWarnings,
255
382
  changes: tracker.build(request.projectSettings, p.baselineProjectSettings, newSettings, (key) => {
256
383
  if (U1_VALUE_KEY_SET.has(key))
257
384
  return "always the U1's own value";
@@ -0,0 +1,13 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ /** The filament the U1 takes, in mm. */
3
+ export declare const U1_FILAMENT_DIAMETER = "1.75";
4
+ /** A filament diameter that isn't the U1's, as a number (2.85 for "2.85"), or null for 1.75 or nothing readable. */
5
+ export declare function offSizeDiameter(value: unknown): number | null;
6
+ /**
7
+ * Sets every slot's `filament_diameter` to the U1's 1.75 mm, with a note for each filament the creator's file had
8
+ * at another size, except the slots in `announced`, which the pipeline has already explained (it set them to a U1
9
+ * preset for their material). Bambu's H3C has a 2.85 mm PrintTool for soft TPU, and its project keeps 2.85 for that
10
+ * filament; left in the file, Snapmaker Orca would compute the extrusion for filament nearly three times thicker and
11
+ * the U1 would badly under-extrude it.
12
+ */
13
+ export declare function setFilamentDiameter(settings: JsonRecord, slotCount: number, warnings: string[], announced?: ReadonlySet<number>): void;
@@ -0,0 +1,30 @@
1
+ /** The filament the U1 takes, in mm. */
2
+ export const U1_FILAMENT_DIAMETER = "1.75";
3
+ /** A filament diameter that isn't the U1's, as a number (2.85 for "2.85"), or null for 1.75 or nothing readable. */
4
+ export function offSizeDiameter(value) {
5
+ const n = typeof value === "string" ? Number.parseFloat(value) : typeof value === "number" ? value : NaN;
6
+ return Number.isFinite(n) && Math.abs(n - Number(U1_FILAMENT_DIAMETER)) > 1e-6 ? n : null;
7
+ }
8
+ /**
9
+ * Sets every slot's `filament_diameter` to the U1's 1.75 mm, with a note for each filament the creator's file had
10
+ * at another size, except the slots in `announced`, which the pipeline has already explained (it set them to a U1
11
+ * preset for their material). Bambu's H3C has a 2.85 mm PrintTool for soft TPU, and its project keeps 2.85 for that
12
+ * filament; left in the file, Snapmaker Orca would compute the extrusion for filament nearly three times thicker and
13
+ * the U1 would badly under-extrude it.
14
+ */
15
+ export function setFilamentDiameter(settings, slotCount, warnings, announced = new Set()) {
16
+ if (slotCount < 1)
17
+ return;
18
+ const raw = settings.filament_diameter;
19
+ const current = Array.isArray(raw) ? raw : raw === undefined ? [] : [raw];
20
+ const changed = [];
21
+ for (let i = 0; i < Math.min(slotCount, current.length); i += 1) {
22
+ const n = offSizeDiameter(current[i]);
23
+ if (n !== null && !announced.has(i))
24
+ changed.push(`filament ${i + 1} (${n} mm)`);
25
+ }
26
+ settings.filament_diameter = Array.from({ length: slotCount }, () => U1_FILAMENT_DIAMETER);
27
+ if (changed.length > 0) {
28
+ warnings.push(` WARN: the U1 takes ${U1_FILAMENT_DIAMETER} mm filament, so ${changed.join(", ")} ${changed.length === 1 ? "is" : "are"} set to ${U1_FILAMENT_DIAMETER} mm; load ${U1_FILAMENT_DIAMETER} mm filament of the same material.`);
29
+ }
30
+ }
@@ -119,7 +119,8 @@ export class ChangeTracker {
119
119
  const gcode = key.endsWith("_gcode");
120
120
  if (!info || (info.group === "filament" && !gcode) || !Object.hasOwn(stock, key) || !Object.hasOwn(output, key))
121
121
  continue;
122
- if (sameSetting(source[key], stock[key]) || !sameSetting(output[key], stock[key]))
122
+ // All G-code in the file is the U1's own: Snapmaker's stock, or that of the U1 preset a filament takes it from.
123
+ if (gcode ? sameSetting(source[key], output[key]) : sameSetting(source[key], stock[key]) || !sameSetting(output[key], stock[key]))
123
124
  continue;
124
125
  if (info.group === "machine" || gcode) {
125
126
  printerSettings++;
package/dist/index.d.ts CHANGED
@@ -10,14 +10,14 @@
10
10
  * `any2orca/worker`.
11
11
  */
12
12
  export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CONVERT_STAGES } from "./project.js";
13
- export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, OpenOptions, ProfileChoice, ReportFilament, ReportFilamentPreset } from "./project.js";
13
+ export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, NozzleUsed, OpenOptions, ProfileChoice, ReportFilament, ReportFilamentPreset } from "./project.js";
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
15
  export { SOURCE_VENDORS } from "./inspect.js";
16
16
  export type { FilamentSlotInfo, Inspection, KnownSourceVendor, SourceVendor } from "./inspect.js";
17
17
  export { SOURCE_FORMATS } from "./sources/reader.js";
18
18
  export type { KnownSourceFormat, SourceFormat } from "./sources/reader.js";
19
- export { SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
20
- export type { KnownNozzleDiameter, SupportedNozzleDiameter } from "./engine/detectNozzleDiameter.js";
19
+ export { DEFAULT_NOZZLE, NOZZLE_CHOICES, SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
20
+ export type { KnownNozzleChoice, KnownNozzleDiameter, NozzleChoice, SupportedNozzleDiameter } from "./engine/detectNozzleDiameter.js";
21
21
  export { fetchProfileSource, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError } from "./profiles.js";
22
22
  export type { MemoryCatalogData, ProfileIndex, ProfileIndexPrinter, ProfileIndexProfile, ProfileIndexRelease, ProfileIndexSource, ProfileSource, ProfileSummary, RetiredProfile, SlicerRelease, } from "./profiles.js";
23
23
  export { resolveFilamentName } from "./engine/filamentComplianceNames.js";
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CON
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
15
  export { SOURCE_VENDORS } from "./inspect.js";
16
16
  export { SOURCE_FORMATS } from "./sources/reader.js";
17
- export { SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
17
+ export { DEFAULT_NOZZLE, NOZZLE_CHOICES, SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
18
18
  export { fetchProfileSource, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError } from "./profiles.js";
19
19
  export { resolveFilamentName } from "./engine/filamentComplianceNames.js";
20
20
  export { Any2orcaError, ANY2ORCA_ERROR_CODES } from "./errors.js";
package/dist/inspect.d.ts CHANGED
@@ -41,7 +41,13 @@ export interface Inspection {
41
41
  filaments: FilamentSlotInfo[];
42
42
  /** The file's first nozzle_diameter as written, e.g. "0.4". */
43
43
  nozzleDiameter: string | null;
44
- /** The supported nozzle size profile matching uses, or null if none could be read. */
44
+ /**
45
+ * Every nozzle size the project uses, as written, smallest first: one entry for most files, several for a project
46
+ * from Bambu Studio's multi-diameter mode (an H3C with a 0.2 PrintTool among 0.4 ones). Empty if the file gives none.
47
+ * Always set by `inspect()`; optional so code that builds an Inspection itself (a test's mock) needn't.
48
+ */
49
+ nozzleDiameters?: string[];
50
+ /** The creator's nozzle size snapped to a U1 size: what converting with `nozzle: "match"` is for. Null if none could be read. */
45
51
  matchNozzleDiameter: SupportedNozzleDiameter | null;
46
52
  layerHeight: number | null;
47
53
  /** The source's process preset, e.g. `"0.20mm Standard @BBL X1C"`. */
@@ -62,7 +68,7 @@ export interface Inspection {
62
68
  * PrusaSlicer 2.9 places its beds in rings with a gap of at most 100 mm, later rows at positive Y. Absent: use that grid.
63
69
  */
64
70
  sourcePlateOrigins?: Record<number, [number, number]>;
65
- /** Non-fatal notes from reading the file. */
71
+ /** Non-fatal notes from reading the file. Their wording can change in any release: check whether there are any, not what they say. */
66
72
  warnings: string[];
67
73
  /**
68
74
  * The project's unpacked size in bytes. Above 1 GB, converting takes a minute or two and a few GB of
package/dist/inspect.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * type-checked rather than cast.
8
8
  */
9
9
  import { lookupFilamentColorName } from "./archive/lookupFilamentColorName.js";
10
- import { detectNozzleDiameter } from "./engine/detectNozzleDiameter.js";
10
+ import { detectNozzleDiameter, sourceNozzleSizes } from "./engine/detectNozzleDiameter.js";
11
11
  import { parseTierName } from "./engine/parseTierName.js";
12
12
  import { plainText } from "./plainText.js";
13
13
  /** The printer makers any2orca recognizes, from a project's printer and preset names; "other" for any it doesn't. */
@@ -100,6 +100,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
100
100
  objects: objects.map((o) => ({ ...o })),
101
101
  filaments,
102
102
  nozzleDiameter: asDisplayString(rawNozzle),
103
+ nozzleDiameters: sourceNozzleSizes(projectSettings).sizes,
103
104
  matchNozzleDiameter: detectNozzleDiameter(projectSettings),
104
105
  layerHeight: Number.isFinite(layerHeightValue) ? layerHeightValue : null,
105
106
  sourcePresetName,
@@ -129,6 +129,7 @@ export declare const ProfileIndexSchema: z.ZodObject<{
129
129
  version: z.ZodString;
130
130
  application: z.ZodString;
131
131
  path: z.ZodUnion<readonly [z.ZodLiteral<".">, z.ZodString]>;
132
+ mixedNozzleSizes: z.ZodOptional<z.ZodBoolean>;
132
133
  }, z.core.$strip>>>;
133
134
  sources: z.ZodOptional<z.ZodObject<{
134
135
  prusaslicer: z.ZodArray<z.ZodObject<{
@@ -174,6 +175,8 @@ export interface ProfileIndexRelease {
174
175
  version: string;
175
176
  application: string;
176
177
  path: string;
178
+ /** This release's U1 presets allow a different nozzle size per toolhead. Absent means no: one size for all four. */
179
+ mixedNozzleSizes?: boolean;
177
180
  }
178
181
  /** A source-slicer data file the catalog holds (PrusaSlicer's vendor preset bundles). */
179
182
  export interface ProfileIndexSource {
@@ -302,6 +305,12 @@ export declare class ProfileCatalog {
302
305
  private filamentPresetsPending;
303
306
  constructor(index: ProfileIndex, source: ProfileSource);
304
307
  /** Every profile, or only one nozzle size's, sorted by nozzle size and then layer height (finest first). */
308
+ /**
309
+ * Whether this catalog's Snapmaker Orca release allows a different nozzle size per toolhead. False for every
310
+ * release so far: Snapmaker Orca takes one size for all four, so a conversion is for one size (`nozzle`). A
311
+ * release that allows mixed sizes says so in its catalog entry, which is where per-toolhead sizes would start.
312
+ */
313
+ get mixedNozzleSizes(): boolean;
305
314
  list(filter?: {
306
315
  nozzleDiameter?: string;
307
316
  }): ProfileSummary[];
package/dist/profiles.js CHANGED
@@ -115,6 +115,8 @@ export const ProfileIndexSchema = z.object({
115
115
  version: VERSION,
116
116
  application: z.string().regex(APPLICATION_VALUE),
117
117
  path: z.union([z.literal("."), z.string().regex(RELEASE_PATH)]),
118
+ /** This release's U1 presets allow a different nozzle size per toolhead. Absent means no: one size for all four. */
119
+ mixedNozzleSizes: z.boolean().optional(),
118
120
  }))
119
121
  .min(1)
120
122
  .max(50)
@@ -248,6 +250,14 @@ export class ProfileCatalog {
248
250
  this.retired = new Map(index.retired.map((r) => [r.id, r]));
249
251
  }
250
252
  /** Every profile, or only one nozzle size's, sorted by nozzle size and then layer height (finest first). */
253
+ /**
254
+ * Whether this catalog's Snapmaker Orca release allows a different nozzle size per toolhead. False for every
255
+ * release so far: Snapmaker Orca takes one size for all four, so a conversion is for one size (`nozzle`). A
256
+ * release that allows mixed sizes says so in its catalog entry, which is where per-toolhead sizes would start.
257
+ */
258
+ get mixedNozzleSizes() {
259
+ return this.index.releases?.find((r) => r.path === ".")?.mixedNozzleSizes === true;
260
+ }
251
261
  list(filter = {}) {
252
262
  const { nozzleDiameter } = filter;
253
263
  return this.summaries.filter((s) => nozzleDiameter === undefined || s.nozzleDiameter === nozzleDiameter).map((s) => ({ ...s }));