any2orca 0.11.0 → 0.12.1
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.
- package/CHANGELOG.md +29 -0
- package/README.md +2 -1
- package/dist/cli/commands/convert.d.ts +2 -1
- package/dist/cli/commands/convert.js +1 -0
- package/dist/cli/commands/nozzle.d.ts +9 -0
- package/dist/cli/commands/nozzle.js +38 -0
- package/dist/cli/config.d.ts +4 -0
- package/dist/cli/config.js +5 -0
- package/dist/cli/main.js +41 -0
- package/dist/cli/surface.d.ts +11 -0
- package/dist/cli/surface.js +3 -0
- package/dist/diff/diffSettings.js +14 -5
- package/dist/engine/applyFilamentComplianceMode.d.ts +3 -1
- package/dist/engine/applyFilamentComplianceMode.js +5 -1
- package/dist/engine/applyFilamentFlowVariants.d.ts +2 -2
- package/dist/engine/applyFilamentFlowVariants.js +4 -4
- package/dist/engine/applyFilamentPresets.d.ts +10 -0
- package/dist/engine/applyFilamentPresets.js +31 -4
- package/dist/engine/detectNozzleDiameter.d.ts +28 -0
- package/dist/engine/detectNozzleDiameter.js +44 -0
- package/dist/engine/detectVariantIndex.d.ts +13 -0
- package/dist/engine/detectVariantIndex.js +25 -13
- package/dist/engine/extractFilamentSlots.js +7 -1
- package/dist/engine/filamentVariantLayout.d.ts +31 -3
- package/dist/engine/filamentVariantLayout.js +54 -2
- package/dist/engine/fillFilamentSlots.js +2 -1
- package/dist/engine/padFilamentsToToolheads.d.ts +20 -0
- package/dist/engine/padFilamentsToToolheads.js +82 -0
- package/dist/engine/policy.d.ts +9 -0
- package/dist/engine/policy.js +37 -0
- package/dist/engine/runConvertPipeline.d.ts +15 -0
- package/dist/engine/runConvertPipeline.js +132 -7
- package/dist/engine/setFilamentDiameter.d.ts +13 -0
- package/dist/engine/setFilamentDiameter.js +30 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/inspect.d.ts +7 -1
- package/dist/inspect.js +2 -1
- package/dist/profiles.d.ts +9 -0
- package/dist/profiles.js +10 -0
- package/dist/project.d.ts +41 -7
- package/dist/project.js +68 -17
- package/dist/stamp.d.ts +12 -0
- package/dist/stamp.js +7 -0
- package/dist/version.js +1 -1
- package/dist/worker-entry.js +5 -1
- package/dist/worker.d.ts +7 -2
- package/dist/worker.js +1 -1
- package/dist/workerProtocol.d.ts +3 -0
- package/package.json +1 -2
|
@@ -16,6 +16,27 @@ function extractVariantNames(bambuSettings) {
|
|
|
16
16
|
}
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* A variant name with whitespace stripped, lowercased: Bambu spells the
|
|
21
|
+
* same variant "Standard"/"HighFlow" in nozzle_volume_type but "Direct
|
|
22
|
+
* Drive High Flow" (with spaces) in the variant-name lists.
|
|
23
|
+
*/
|
|
24
|
+
export function variantKey(name) {
|
|
25
|
+
return name.replace(/\s+/g, "").toLowerCase();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The flow variant a single-nozzle source was sliced with, from
|
|
29
|
+
* `nozzle_volume_type` (or `default_nozzle_volume_type`), as a
|
|
30
|
+
* {@link variantKey}; `null` when the source doesn't say. Scoped to one
|
|
31
|
+
* physical nozzle for the reason given on detectVariantIndex.
|
|
32
|
+
*/
|
|
33
|
+
export function activeNozzleVolumeType(bambuSettings) {
|
|
34
|
+
const nozzleDiameter = bambuSettings.nozzle_diameter;
|
|
35
|
+
if (!Array.isArray(nozzleDiameter) || nozzleDiameter.length !== 1)
|
|
36
|
+
return null;
|
|
37
|
+
const raw = bambuSettings.nozzle_volume_type ?? bambuSettings.default_nozzle_volume_type;
|
|
38
|
+
return Array.isArray(raw) && typeof raw[0] === "string" && raw[0] ? variantKey(raw[0]) : null;
|
|
39
|
+
}
|
|
19
40
|
/**
|
|
20
41
|
* Determines which column of Bambu's newer per-nozzle-variant paired
|
|
21
42
|
* arrays (e.g. `outer_wall_speed: ["210", "350"]`) reflects the settings
|
|
@@ -48,22 +69,13 @@ function extractVariantNames(bambuSettings) {
|
|
|
48
69
|
* existing "can't determine, ask for manual review" behavior in that case.
|
|
49
70
|
*/
|
|
50
71
|
export function detectVariantIndex(bambuSettings) {
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
72
|
+
const active = activeNozzleVolumeType(bambuSettings);
|
|
73
|
+
if (active === null)
|
|
53
74
|
return null;
|
|
54
75
|
const names = extractVariantNames(bambuSettings);
|
|
55
76
|
if (!names)
|
|
56
77
|
return null;
|
|
57
|
-
const
|
|
58
|
-
const activeVariant = Array.isArray(activeVariantRaw) && typeof activeVariantRaw[0] === "string" ? activeVariantRaw[0] : null;
|
|
59
|
-
if (!activeVariant)
|
|
60
|
-
return null;
|
|
61
|
-
// Compare with whitespace stripped -- Bambu spells the same variant
|
|
62
|
-
// "Standard"/"HighFlow" in nozzle_volume_type but "Direct Drive High
|
|
63
|
-
// Flow" (with spaces) in the variant-name lists.
|
|
64
|
-
const normalize = (s) => s.replace(/\s+/g, "").toLowerCase();
|
|
65
|
-
const activeNormalized = normalize(activeVariant);
|
|
66
|
-
const index = names.findIndex((n) => normalize(n).includes(activeNormalized));
|
|
78
|
+
const index = names.findIndex((n) => variantKey(n).includes(active));
|
|
67
79
|
return index >= 0 ? index : 0;
|
|
68
80
|
}
|
|
69
81
|
/**
|
|
@@ -75,6 +87,6 @@ export function detectHighFlowVariantIndex(bambuSettings) {
|
|
|
75
87
|
const names = extractVariantNames(bambuSettings);
|
|
76
88
|
if (!names)
|
|
77
89
|
return null;
|
|
78
|
-
const index = names.findIndex((n) => n
|
|
90
|
+
const index = names.findIndex((n) => variantKey(n).includes("highflow"));
|
|
79
91
|
return index >= 0 ? index : null;
|
|
80
92
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import { FILAMENT_FLOW_VARIANT_KEYS } from "./applyFilamentFlowVariants.js";
|
|
3
3
|
import { detectVariantIndex } from "./detectVariantIndex.js";
|
|
4
|
-
import { filamentVariantLayout } from "./filamentVariantLayout.js";
|
|
4
|
+
import { bambuFilamentVariantLayout, filamentVariantLayout } from "./filamentVariantLayout.js";
|
|
5
5
|
import { reshapeToCount } from "./reshapeToCount.js";
|
|
6
6
|
const VARIANT_KEYS = new Set(FILAMENT_FLOW_VARIANT_KEYS);
|
|
7
7
|
/** Up to six setting names, then how many more. */
|
|
@@ -33,6 +33,8 @@ export function extractFilamentSlots(bambuSettings, filamentTemplateKeys, extraP
|
|
|
33
33
|
const variantIndex = detectVariantIndex(bambuSettings) ?? 0;
|
|
34
34
|
// A source saved by an Orca-family slicer says where each filament's standard value sits, even when filaments carry different numbers of values.
|
|
35
35
|
const layout = filamentVariantLayout(bambuSettings, filamentCount);
|
|
36
|
+
// A Bambu Studio source names each value's filament and variant instead, so filaments with different numbers of values are read correctly too.
|
|
37
|
+
const bambuLayout = layout ? null : bambuFilamentVariantLayout(bambuSettings, filamentCount);
|
|
36
38
|
const perProjectKeyArrays = {};
|
|
37
39
|
// Stale lists usually affect dozens of settings at once; they're reported as one line per kind, not one per setting.
|
|
38
40
|
const stockUsed = new Map();
|
|
@@ -49,6 +51,10 @@ export function extractFilamentSlots(bambuSettings, filamentTemplateKeys, extraP
|
|
|
49
51
|
perProjectKeyArrays[key] = layout.slots.map((slot) => bval[slot.standard]);
|
|
50
52
|
continue;
|
|
51
53
|
}
|
|
54
|
+
if (bambuLayout && bval.length === bambuLayout.length) {
|
|
55
|
+
perProjectKeyArrays[key] = bambuLayout.slots.map((slot) => bval[slot.standard]);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
52
58
|
// Several values per filament are read as one per nozzle variant only when the file names the variants;
|
|
53
59
|
// otherwise the extra values are stale entries, and the first one per filament is used, as the slicer does.
|
|
54
60
|
const variantNames = bambuSettings.filament_extruder_variant;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { JsonRecord } from "./types.js";
|
|
2
|
-
/** Where one filament's values sit in a per-variant array of
|
|
2
|
+
/** Where one filament's values sit in a per-variant array of the source. */
|
|
3
3
|
export interface FilamentVariantPositions {
|
|
4
|
-
/** Index of the filament's standard value. */
|
|
4
|
+
/** Index of the value the converted file's standard value comes from: the filament's standard value (for a Bambu Studio source, the variant it was sliced with). */
|
|
5
5
|
standard: number;
|
|
6
6
|
/** Index of its high-flow value, or null when the filament has none. */
|
|
7
7
|
highFlow: number | null;
|
|
@@ -24,6 +24,34 @@ export interface FilamentVariantLayout {
|
|
|
24
24
|
* in one file can have different counts (a filament with only a standard
|
|
25
25
|
* value next to one with both), so the array isn't always a clean multiple
|
|
26
26
|
* of the slot count. Bambu Studio sources don't write these keys; they
|
|
27
|
-
* name their variants instead (
|
|
27
|
+
* name their variants instead (bambuFilamentVariantLayout).
|
|
28
28
|
*/
|
|
29
29
|
export declare function filamentVariantLayout(source: JsonRecord, slotCount: number): FilamentVariantLayout | null;
|
|
30
|
+
/** Which entries of a Bambu Studio source's per-variant filament settings belong to each filament. */
|
|
31
|
+
export interface BambuFilamentEntries {
|
|
32
|
+
/** How many entries a per-variant filament setting has in this source. */
|
|
33
|
+
length: number;
|
|
34
|
+
/** One list of entry indexes per filament slot, in slot order. */
|
|
35
|
+
entries: number[][];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Which entries of a Bambu Studio source's per-variant filament settings
|
|
39
|
+
* belong to each filament, or null when the source doesn't say or every
|
|
40
|
+
* filament has one value.
|
|
41
|
+
*
|
|
42
|
+
* Bambu Studio stores a value only for the nozzle variants each filament's
|
|
43
|
+
* preset has (Generic PLA: standard only; Bambu PLA Basic: standard and
|
|
44
|
+
* high flow), and names each entry's filament in `filament_self_index`
|
|
45
|
+
* (from 1) and its variant in `filament_extruder_variant` ("Direct Drive
|
|
46
|
+
* Standard", "Direct Drive High Flow"), so four filaments can have seven
|
|
47
|
+
* values.
|
|
48
|
+
*/
|
|
49
|
+
export declare function bambuFilamentEntries(source: JsonRecord, slotCount: number): BambuFilamentEntries | null;
|
|
50
|
+
/**
|
|
51
|
+
* How a Bambu Studio source lays out its per-variant filament settings
|
|
52
|
+
* (bambuFilamentEntries), or null. Each filament reads its entry for the
|
|
53
|
+
* variant the source was sliced with (activeNozzleVolumeType), or its first
|
|
54
|
+
* entry when it has none for that variant or the source doesn't say, as
|
|
55
|
+
* the slicer does (get_index_for_extruder in PrintConfig.cpp).
|
|
56
|
+
*/
|
|
57
|
+
export declare function bambuFilamentVariantLayout(source: JsonRecord, slotCount: number): FilamentVariantLayout | null;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { activeNozzleVolumeType, variantKey } from "./detectVariantIndex.js";
|
|
3
|
+
/** Most variants a slicer stores for one filament (standard and high flow today). */
|
|
2
4
|
const MAX_STEP = 4;
|
|
3
5
|
/**
|
|
4
6
|
* How a source saved by Snapmaker Orca (or another Orca-family slicer)
|
|
@@ -12,7 +14,7 @@ const MAX_STEP = 4;
|
|
|
12
14
|
* in one file can have different counts (a filament with only a standard
|
|
13
15
|
* value next to one with both), so the array isn't always a clean multiple
|
|
14
16
|
* of the slot count. Bambu Studio sources don't write these keys; they
|
|
15
|
-
* name their variants instead (
|
|
17
|
+
* name their variants instead (bambuFilamentVariantLayout).
|
|
16
18
|
*/
|
|
17
19
|
export function filamentVariantLayout(source, slotCount) {
|
|
18
20
|
const steps = source.filament_flow_step_size;
|
|
@@ -36,3 +38,53 @@ export function filamentVariantLayout(source, slotCount) {
|
|
|
36
38
|
}
|
|
37
39
|
return { length, slots };
|
|
38
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Which entries of a Bambu Studio source's per-variant filament settings
|
|
43
|
+
* belong to each filament, or null when the source doesn't say or every
|
|
44
|
+
* filament has one value.
|
|
45
|
+
*
|
|
46
|
+
* Bambu Studio stores a value only for the nozzle variants each filament's
|
|
47
|
+
* preset has (Generic PLA: standard only; Bambu PLA Basic: standard and
|
|
48
|
+
* high flow), and names each entry's filament in `filament_self_index`
|
|
49
|
+
* (from 1) and its variant in `filament_extruder_variant` ("Direct Drive
|
|
50
|
+
* Standard", "Direct Drive High Flow"), so four filaments can have seven
|
|
51
|
+
* values.
|
|
52
|
+
*/
|
|
53
|
+
export function bambuFilamentEntries(source, slotCount) {
|
|
54
|
+
const owners = source.filament_self_index;
|
|
55
|
+
const variants = source.filament_extruder_variant;
|
|
56
|
+
if (!Array.isArray(owners) || !Array.isArray(variants) || slotCount < 1 || owners.length !== variants.length)
|
|
57
|
+
return null;
|
|
58
|
+
if (owners.length <= slotCount || owners.length > slotCount * MAX_STEP || !variants.every((v) => typeof v === "string"))
|
|
59
|
+
return null;
|
|
60
|
+
const entries = Array.from({ length: slotCount }, () => []);
|
|
61
|
+
for (const [index, owner] of owners.entries()) {
|
|
62
|
+
const n = typeof owner === "string" || typeof owner === "number" ? Number(owner) : NaN;
|
|
63
|
+
if (!Number.isInteger(n) || n < 1 || n > slotCount)
|
|
64
|
+
return null;
|
|
65
|
+
entries[n - 1].push(index);
|
|
66
|
+
}
|
|
67
|
+
if (entries.some((own) => own.length === 0 || own.length > MAX_STEP))
|
|
68
|
+
return null;
|
|
69
|
+
return { length: owners.length, entries };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* How a Bambu Studio source lays out its per-variant filament settings
|
|
73
|
+
* (bambuFilamentEntries), or null. Each filament reads its entry for the
|
|
74
|
+
* variant the source was sliced with (activeNozzleVolumeType), or its first
|
|
75
|
+
* entry when it has none for that variant or the source doesn't say, as
|
|
76
|
+
* the slicer does (get_index_for_extruder in PrintConfig.cpp).
|
|
77
|
+
*/
|
|
78
|
+
export function bambuFilamentVariantLayout(source, slotCount) {
|
|
79
|
+
const found = bambuFilamentEntries(source, slotCount);
|
|
80
|
+
if (!found)
|
|
81
|
+
return null;
|
|
82
|
+
const names = source.filament_extruder_variant.map(variantKey);
|
|
83
|
+
const active = activeNozzleVolumeType(source);
|
|
84
|
+
const find = (own, variant) => own.find((index) => names[index].includes(variant));
|
|
85
|
+
const slots = found.entries.map((own) => ({
|
|
86
|
+
standard: (active === null ? undefined : find(own, active)) ?? own[0],
|
|
87
|
+
highFlow: find(own, "highflow") ?? null,
|
|
88
|
+
}));
|
|
89
|
+
return { length: found.length, slots };
|
|
90
|
+
}
|
|
@@ -19,7 +19,8 @@ export function fillFilamentSlots(settings, filamentKeys, fromSource, slotCount)
|
|
|
19
19
|
if (fromSource.has(key))
|
|
20
20
|
continue;
|
|
21
21
|
const value = settings[key];
|
|
22
|
-
|
|
22
|
+
// Always one filament's values, even a standard and high-flow pair in a two-filament project.
|
|
23
|
+
if (!Array.isArray(value) || value.length === 0)
|
|
23
24
|
continue;
|
|
24
25
|
settings[key] = Array.from({ length: slotCount }, () => value[0]);
|
|
25
26
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { JsonRecord } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* The colors Snapmaker Orca gives the filaments it adds, in order (Plater.cpp, get_next_color_for_filament). The app
|
|
4
|
+
* keeps one counter for the whole session, so these are the colors a freshly started app gives its first ones.
|
|
5
|
+
*/
|
|
6
|
+
export declare const NEW_FILAMENT_COLORS: readonly string[];
|
|
7
|
+
/**
|
|
8
|
+
* Pads a project with fewer filaments than the printer has toolheads to one filament per toolhead, as Snapmaker Orca
|
|
9
|
+
* does when a project is switched to a printer with several (Tab.cpp, "sync filament num if it's a multi tool
|
|
10
|
+
* printer"): each added filament is a copy of the last one, its preset, parent and settings included, in the next of
|
|
11
|
+
* the app's new-filament colors the project doesn't use. No object uses the copies, and the project's own filaments
|
|
12
|
+
* stay as they are. A file with fewer is set up for every toolhead anyway when the app opens it, and then checked
|
|
13
|
+
* against its own shorter lists: the app lists a nameless preset as customized and marks a one-filament project's
|
|
14
|
+
* filament modified. Printers with more toolheads than the palette has colors are left alone.
|
|
15
|
+
*
|
|
16
|
+
* @param filamentKeys the profile's filament settings (its filament template), which the converter reads per filament
|
|
17
|
+
* when it converts a file again, besides those the settings catalog lists as filament settings.
|
|
18
|
+
* @returns how many filaments were added.
|
|
19
|
+
*/
|
|
20
|
+
export declare function padFilamentsToToolheads(settings: JsonRecord, slotCount: number, toolheads: number, filamentKeys?: ReadonlySet<string>): number;
|
|
@@ -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
|
+
}
|
package/dist/engine/policy.d.ts
CHANGED
|
@@ -18,6 +18,15 @@ 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[];
|
|
23
32
|
/**
|
package/dist/engine/policy.js
CHANGED
|
@@ -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",
|
|
@@ -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 { filamentBases, listFilamentSettings, writeBaseGcode, 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
|
-
|
|
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
|
}
|
|
@@ -227,11 +338,24 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
227
338
|
warnings.push(...shiftWarnings);
|
|
228
339
|
addShiftItems(tracker, request.objects, shifts);
|
|
229
340
|
// Last of the filament steps: the chosen presets' settings, each U1 base preset's G-code, then each filament's
|
|
230
|
-
// changed settings named against the preset Snapmaker Orca resets it to, so it keeps what the file says
|
|
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
344
|
const bases = filamentBases(newSettings, slotCount, printer.filamentPresets, printer.filamentNames, printer.id, Boolean(request.filamentComplianceMode));
|
|
233
345
|
writeBaseGcode(newSettings, filamentFiles, bases, slotCount);
|
|
234
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
|
+
}
|
|
235
359
|
const configFiles = { ...filamentFiles };
|
|
236
360
|
// `warnings` mixes routine per-conversion bookkeeping (e.g. computeShifts'
|
|
237
361
|
// "true geometric center -> target" line, which fires on every plate
|
|
@@ -251,9 +375,10 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
251
375
|
...(filamentComplianceFallback ? { filamentComplianceFallback } : {}),
|
|
252
376
|
...(filamentComplianceUnchanged ? { filamentComplianceUnchanged } : {}),
|
|
253
377
|
...(appliedPresets.length > 0 ? { filamentPresets: appliedPresets.map((a) => ({ slot: a.slot + 1, preset: a.preset, changed: a.changed })) } : {}),
|
|
254
|
-
...(userFacingWarnings.length > 0 ? { warnings: userFacingWarnings } : {}),
|
|
378
|
+
...(userFacingWarnings.length > 0 ? { warnings: userFacingWarnings.filter((w) => !leadWarnings.includes(w)) } : {}),
|
|
255
379
|
},
|
|
256
380
|
warnings,
|
|
381
|
+
leadWarnings,
|
|
257
382
|
changes: tracker.build(request.projectSettings, p.baselineProjectSettings, newSettings, (key) => {
|
|
258
383
|
if (U1_VALUE_KEY_SET.has(key))
|
|
259
384
|
return "always the U1's own value";
|