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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# any2orca
|
|
2
2
|
|
|
3
|
+
## 0.12.1
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- **The worker's `matchProfile` takes the nozzle size.** `project.matchProfile({ nozzle: "0.6" })` from `any2orca/worker` picks among the profiles for that size, or for the creator's size with `"match"`, the same way `convert` does with the same option, so a page can show the profile a conversion will use without matching on its own thread.
|
|
8
|
+
|
|
9
|
+
### Other
|
|
10
|
+
|
|
11
|
+
- **The web app says which nozzle size a file was converted for, and its FAQ explains the nozzle setting.** The result line and What changed read "for 0.4 mm nozzles" (or the size chosen), in single and batch conversion, and a new FAQ answer says which size a file is made for and why a filament tuned for another nozzle size or diameter takes Snapmaker's preset's settings. The profile shown before converting now comes from the converter itself for every nozzle size.
|
|
12
|
+
|
|
13
|
+
## 0.12.0
|
|
14
|
+
|
|
15
|
+
### Output-affecting
|
|
16
|
+
|
|
17
|
+
- **Snapmaker Orca no longer opens a converted file with its first filament marked as modified.** Each filament's embedded preset (`Metadata/filament_settings_N.config`) held the source file's values as they were before the conversion laid them out for the U1: one value where the U1 keeps a standard and a high-flow value, no parent preset, and the filament's color as its default color. It didn't match the filament it was written for, and Snapmaker Orca marked the first filament modified whenever its name appeared only once in the file. Now each embedded preset holds what the file holds for its filament, with its parent in `inherits`. Only the embedded presets change; the project settings are the same.
|
|
18
|
+
- **Files are converted for the nozzle size your U1 has, 0.4 mm unless you say otherwise, instead of the size the creator used.** A MakerWorld project sliced for a 0.6 mm nozzle used to become a U1 0.6 conversion, which the U1's firmware refuses at print start when 0.4 mm nozzles are installed. Now the profile, its layer heights and the filament values are the U1's for your size, the creator's size is noted when it differs (with a What changed item under Your choices), and a project that mixes nozzle sizes (Bambu Studio's multi-diameter mode, as on the H3C) is converted for your size with a note naming the filaments that were on other sizes. A project that names no nozzle size is converted for your size too, matched by its layer height, where it used to get the catalog's default profile whatever its layer height. A filament the creator tuned for another nozzle size than the file is for keeps its name, color, temperatures and other filament facts, but takes the U1 preset's calibration for its material at your size (flow ratio, max volumetric speed, pressure advance, retraction, cooling), since those described the creator's nozzle; the first note names the filaments, and the color is unchanged so a preset of your own can be chosen in Snapmaker Orca. The size is one for all four toolheads, as Snapmaker Orca allows; a release that allows a different size per toolhead will say so in its profile catalog (`catalog.mixedNozzleSizes`), which is where per-toolhead sizes would start. Library: the `nozzle` option on `convert()` and `matchProfile()` (`"0.2"` to `"0.8"`, or `"match"` for the creator's size, the old behavior); `NOZZLE_CHOICES` and `DEFAULT_NOZZLE`; `report.nozzle` and `ProfileChoice.nozzle` say what was used; `inspection.nozzleDiameters` lists every size a project uses; the version note records `options.nozzle`. CLI: `--nozzle <size|match>` on `convert`, and `any2orca nozzle <size>` saves your size in the config file for every conversion. Refused together with a `--profile` or preset of another size.
|
|
19
|
+
- **A project with fewer than four filaments gets copies of its last filament for the U1's other toolheads, as Snapmaker Orca adds them when a project is switched to the U1.** The creator's filaments stay first, unchanged and in order; each copy has the last filament's preset and settings and a new color, the first of Snapmaker Orca's new-filament colors (teal, cream, red) the project doesn't already use. No object uses the copies, and What changed says how many were added. Snapmaker Orca sets every U1 project up for four toolheads when it opens one, and a file with fewer filaments opened with a "Customized Preset" notice naming no preset, and with one filament, with that filament marked modified.
|
|
20
|
+
- **In a project with exactly two filaments, the second one now gets Snapmaker's standard values for the filament settings the source file doesn't have.** It got Snapmaker's high-flow values instead, because a stock standard and high-flow pair was read as one value for each of the two filaments: a ramming flow of 40 at tool changes instead of 30 in every such file, and, in files without them, a max volumetric speed of 40 (capped to 22, with a note) instead of 20 and a pressure advance of 0.024 instead of 0.02. Projects with one, three or more filaments were right.
|
|
21
|
+
- **A Bambu Studio project mixing filaments with and without a high-flow value keeps the creator's filament settings.** Bambu Studio stores a value only for the nozzle variants each filament's preset has (Generic PLA has a standard value only), so four filaments can have seven values for one setting. Those lists were read as stale, and 20 filament settings, including nozzle temperatures, flow ratio, max volumetric speed, retraction and Z hop, got Snapmaker's stock values for every filament, with a warning: a max volumetric speed of 20 mm³/s for Generic PLA where the file has 12. Now each filament's values, its high-flow value included, are read from where the file says they are, as Bambu Studio reads them. Projects where every filament has the same number of values were right.
|
|
22
|
+
- **A filament the creator's printer took at another diameter is set to a U1 preset for its material, and every filament in a converted file is 1.75 mm.** A Bambu H3C project keeps 2.85 mm for a filament on its 2.85 mm TPU PrintTool, with values tuned for that filament in that tool (a flow ratio of 1.21, for one); left in the file, Snapmaker Orca computed the extrusion for filament nearly three times thicker, and the values would have been wrong for 1.75 mm filament anyway. That filament now takes Snapmaker's preset for its material (Generic's where Snapmaker has none, or when you chose the Generic option) with that preset's settings; its color, material and place in the order stay. The first note of the conversion says so and asks you to load 1.75 mm filament and check the preset's settings, since the creator's filament may print differently; What changed lists it under the firmware group. A filament whose material has no U1 preset keeps the creator's settings with its diameter set to 1.75 mm, with the same note.
|
|
23
|
+
|
|
24
|
+
### Fixes
|
|
25
|
+
|
|
26
|
+
- **Comparing settings (`any2orca diff`, and the full comparison in What changed) shows a Bambu Studio project's filament settings one filament at a time when its filaments have different numbers of values.** Bambu Studio stores a value only for the nozzle variants each filament's preset has (Generic PLA has a standard value only), and those settings were listed as one row covering every filament.
|
|
27
|
+
|
|
28
|
+
### Other
|
|
29
|
+
|
|
30
|
+
- **The web app has a "Your U1's nozzle size" setting.** Next to the Liber High Flow Hotend toggle: 0.2, 0.4, 0.6 or 0.8 mm, or "Match the file" for the size the creator used. It's remembered between visits, the profile picker lists the profiles for that size, and every conversion, batch conversion and preset match uses it. The help text says what it changes and that Snapmaker Orca uses one size for all four toolheads.
|
|
31
|
+
|
|
3
32
|
## 0.11.0
|
|
4
33
|
|
|
5
34
|
### Output-affecting
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ Useful options:
|
|
|
17
17
|
|
|
18
18
|
| Option | What it does |
|
|
19
19
|
|---|---|
|
|
20
|
+
| `--nozzle <size\|match>` | The nozzle size your U1 has, which the file is made for: 0.2, 0.4 (default), 0.6 or 0.8, or `match` for the creator's size. `any2orca nozzle 0.6` saves it for every conversion |
|
|
20
21
|
| `--profile <id>` | Use this profile instead of matching one |
|
|
21
22
|
| `--snapmaker-orca-version <x.y.z>` | Convert for the Snapmaker Orca release you slice with (default: the newest) |
|
|
22
23
|
| `--high-flow`, `--high-flow-toolheads 1,3` | All toolheads, or only these, have the Liber High Flow Hotend |
|
|
@@ -37,7 +38,7 @@ Every exported function and type is in the [API reference](https://docs.any2orca
|
|
|
37
38
|
|
|
38
39
|
What stays stable: everything the library exports is supported, and a release only adds to it. A new option is optional, a result can gain fields, an interface you implement yourself (such as `ProfileSource`) only gains optional members, and a list of values the library returns (a source maker, an error code, a change reason, a conversion stage, a diff status) can gain values, so handle one you don't recognize; each list's known values are exported next to its type, for example `SOURCE_VENDORS` beside `SourceVendor`. A file format (the output stamp, a presets file, the profile catalog, the stats event) changes shape only with a new version number, and older ones keep being read. Nothing is removed or renamed outside a major release, and only after a deprecation notice. The same holds for the CLI's commands, flags, exit codes and JSON output, and for the partner hand-off. Checks in CI compare the API's shape, and the CLI's commands and options, with committed records, so a change to either is deliberate.
|
|
39
40
|
|
|
40
|
-
Every filament in the source stays in the output: all of them, with their colors, brands, types and order, however many. The U1 loads four at a time, but a project can use many more, swapped in at the pauses the user plans in Snapmaker Orca, and that planning depends on the file's own order. `report.filaments` lists each
|
|
41
|
+
Every filament in the source stays in the output: all of them, with their colors, brands, types and order, however many. The U1 loads four at a time, but a project can use many more, swapped in at the pauses the user plans in Snapmaker Orca, and that planning depends on the file's own order. A project with fewer filaments than the U1's four toolheads gets copies of its last filament up to four, as Snapmaker Orca adds them when a project is switched to the U1, each in a new color; no object uses them, and What changed says so. `report.filaments` lists each of the source's slots with the name it had and the name it has. The model's own metadata in `3D/3dmodel.model` (designer, license, copyright, title, description) stays as it was; only `Application` changes, to the Snapmaker Orca release the file is made for.
|
|
41
42
|
|
|
42
43
|
```js
|
|
43
44
|
import { readFile, writeFile } from "node:fs/promises";
|
|
@@ -12,7 +12,8 @@ export interface ConvertOptions {
|
|
|
12
12
|
/** --use-stock / --keep-higher: the choice for values above stock. */
|
|
13
13
|
aboveStock?: AboveStockChoice;
|
|
14
14
|
filamentCompliance?: "generic" | "snapmaker";
|
|
15
|
-
/**
|
|
15
|
+
/** The nozzle size the user's U1 has ("0.4"), or "match" for the creator's; what every file is converted for. */
|
|
16
|
+
nozzle: string;
|
|
16
17
|
/** All toolheads have the Liber hotend (true), or exactly these ones, T1 first. */
|
|
17
18
|
highFlow?: boolean | boolean[];
|
|
18
19
|
hardenedNozzle?: boolean;
|
|
@@ -138,6 +138,7 @@ async function convertOne(entryName, bytes, defaultDir, originalInputPath, optio
|
|
|
138
138
|
}
|
|
139
139
|
const { output, report } = await project.convert({
|
|
140
140
|
profiles: options.catalog,
|
|
141
|
+
nozzle: options.nozzle,
|
|
141
142
|
...(options.profile ? { profileId: options.profile } : {}),
|
|
142
143
|
...(options.preset ? { preset: options.preset } : {}),
|
|
143
144
|
...(options.aboveStock ? { aboveStock: options.aboveStock } : {}),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type Env } from "../config.js";
|
|
2
|
+
/** What `convert` is for when it has no `--nozzle`: the saved size, else the U1's stock 0.4. */
|
|
3
|
+
export declare function savedNozzle(env: Env): string;
|
|
4
|
+
/** A `--nozzle` value or a size to save, checked: a size in mm such as "0.4", or "match". */
|
|
5
|
+
export declare function parseNozzleChoice(value: string, where: string): string;
|
|
6
|
+
/** `any2orca nozzle` / `any2orca nozzle show`: the saved size and what it means. */
|
|
7
|
+
export declare function runNozzleShow(env: Env, out: (line: string) => void): void;
|
|
8
|
+
export declare function runNozzleSet(value: string, env: Env, out: (line: string) => void): void;
|
|
9
|
+
export declare function runNozzleClear(env: Env, out: (line: string) => void): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
import { DEFAULT_NOZZLE, NOZZLE_CHOICES } from "../../engine/detectNozzleDiameter.js";
|
|
3
|
+
import { NOZZLE_CHOICE_TEXT, readCliConfig, updateCliConfig } from "../config.js";
|
|
4
|
+
const choices = NOZZLE_CHOICES.join(", ");
|
|
5
|
+
/** What `convert` is for when it has no `--nozzle`: the saved size, else the U1's stock 0.4. */
|
|
6
|
+
export function savedNozzle(env) {
|
|
7
|
+
return readCliConfig(env).nozzle ?? DEFAULT_NOZZLE;
|
|
8
|
+
}
|
|
9
|
+
/** A `--nozzle` value or a size to save, checked: a size in mm such as "0.4", or "match". */
|
|
10
|
+
export function parseNozzleChoice(value, where) {
|
|
11
|
+
const trimmed = value.trim();
|
|
12
|
+
if (!NOZZLE_CHOICE_TEXT.test(trimmed))
|
|
13
|
+
throw new Error(`${where} takes a nozzle size in mm, or "match" for the creator's size: ${choices} (got "${value}")`);
|
|
14
|
+
return trimmed;
|
|
15
|
+
}
|
|
16
|
+
/** `any2orca nozzle` / `any2orca nozzle show`: the saved size and what it means. */
|
|
17
|
+
export function runNozzleShow(env, out) {
|
|
18
|
+
const saved = readCliConfig(env).nozzle;
|
|
19
|
+
if (saved === undefined)
|
|
20
|
+
out(`Nozzle size: ${DEFAULT_NOZZLE} mm (the U1's stock size; nothing saved).`);
|
|
21
|
+
else if (saved === "match")
|
|
22
|
+
out("Nozzle size: match (each file is converted for the size the creator used).");
|
|
23
|
+
else
|
|
24
|
+
out(`Nozzle size: ${saved} mm (saved).`);
|
|
25
|
+
out(` Every "any2orca convert" without --nozzle is for this size. Save another with: any2orca nozzle <size> (${choices}); forget it with: any2orca nozzle clear.`);
|
|
26
|
+
}
|
|
27
|
+
export function runNozzleSet(value, env, out) {
|
|
28
|
+
const choice = parseNozzleChoice(value, "any2orca nozzle");
|
|
29
|
+
updateCliConfig((c) => ({ ...c, nozzle: choice }), env);
|
|
30
|
+
out(choice === "match" ? "Saved: each file is converted for the nozzle size the creator used." : `Saved: conversions are for ${choice} mm nozzles.`);
|
|
31
|
+
}
|
|
32
|
+
export function runNozzleClear(env, out) {
|
|
33
|
+
updateCliConfig((c) => {
|
|
34
|
+
const { nozzle: _, ...rest } = c;
|
|
35
|
+
return rest;
|
|
36
|
+
}, env);
|
|
37
|
+
out(`Cleared: conversions are for ${DEFAULT_NOZZLE} mm nozzles, the U1's stock size.`);
|
|
38
|
+
}
|
package/dist/cli/config.d.ts
CHANGED
|
@@ -9,7 +9,11 @@ export interface CliConfig {
|
|
|
9
9
|
latest?: string;
|
|
10
10
|
outputAffecting?: string;
|
|
11
11
|
};
|
|
12
|
+
/** The nozzle size the user's U1 has, used by every `convert` without `--nozzle`: a size such as "0.6", or "match". */
|
|
13
|
+
nozzle?: string;
|
|
12
14
|
}
|
|
15
|
+
/** A nozzle choice as the config file or `--nozzle` may give it: a size in mm, or "match" for the creator's. */
|
|
16
|
+
export declare const NOZZLE_CHOICE_TEXT: RegExp;
|
|
13
17
|
export type Env = Record<string, string | undefined>;
|
|
14
18
|
export declare function configDir(env?: Env): string;
|
|
15
19
|
export declare function readCliConfig(env?: Env): CliConfig;
|
package/dist/cli/config.js
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { homedir } from "node:os";
|
|
12
12
|
import { join } from "node:path";
|
|
13
|
+
/** A nozzle choice as the config file or `--nozzle` may give it: a size in mm, or "match" for the creator's. */
|
|
14
|
+
export const NOZZLE_CHOICE_TEXT = /^(\d{1,2}(\.\d{1,3})?|match)$/;
|
|
13
15
|
export function configDir(env = process.env) {
|
|
14
16
|
if (env.ANY2ORCA_CONFIG_DIR)
|
|
15
17
|
return env.ANY2ORCA_CONFIG_DIR;
|
|
@@ -64,6 +66,9 @@ function checkedConfig(value) {
|
|
|
64
66
|
checked.outputAffecting = updateCheck.outputAffecting.slice(0, 300);
|
|
65
67
|
config.updateCheck = checked;
|
|
66
68
|
}
|
|
69
|
+
const { nozzle } = value;
|
|
70
|
+
if (typeof nozzle === "string" && NOZZLE_CHOICE_TEXT.test(nozzle))
|
|
71
|
+
config.nozzle = nozzle;
|
|
67
72
|
return config;
|
|
68
73
|
}
|
|
69
74
|
/** Writes atomically (temp file + rename), so a crash never leaves a half-written config. */
|
package/dist/cli/main.js
CHANGED
|
@@ -13,6 +13,7 @@ import { runDiff } from "./commands/diff.js";
|
|
|
13
13
|
import { presetForConvert, presetForDiff, runPresetsAdd, runPresetsExport, runPresetsImport, runPresetsList, runPresetsRemove, runPresetsShow, } from "./commands/presets.js";
|
|
14
14
|
import { resolveAboveStockChoice } from "../engine/aboveStock.js";
|
|
15
15
|
import { runProfiles } from "./commands/profiles.js";
|
|
16
|
+
import { parseNozzleChoice, runNozzleClear, runNozzleSet, runNozzleShow, savedNozzle } from "./commands/nozzle.js";
|
|
16
17
|
import { runTelemetryClear, runTelemetrySet, runTelemetryShow, runUpdateCheckSet } from "./commands/telemetry.js";
|
|
17
18
|
import { readCliConfig } from "./config.js";
|
|
18
19
|
import { expandInputPatterns } from "./expandWildcards.js";
|
|
@@ -56,6 +57,7 @@ ${formatOptions([
|
|
|
56
57
|
["diff <a.3mf> <b.3mf>", "Compare the settings of two projects, or one with Snapmaker's stock profile"],
|
|
57
58
|
["presets add | list | show | ...", "Save your own tuned print settings from a 3MF and convert with them"],
|
|
58
59
|
["profiles", "List the profiles convert can use"],
|
|
60
|
+
["nozzle [<size> | match | clear]", "Say which nozzle size your U1 has (default 0.4 mm), for every conversion"],
|
|
59
61
|
["telemetry show | on | off | clear", "Show or change usage stats and the update check"],
|
|
60
62
|
["--version", "Print the version"],
|
|
61
63
|
])}
|
|
@@ -150,6 +152,25 @@ ${formatOptions([
|
|
|
150
152
|
["-h, --help", "Show this help"],
|
|
151
153
|
])}
|
|
152
154
|
`;
|
|
155
|
+
const NOZZLE_HELP = `Usage: any2orca nozzle
|
|
156
|
+
any2orca nozzle <size> | match
|
|
157
|
+
any2orca nozzle clear
|
|
158
|
+
|
|
159
|
+
Says which nozzle size your U1 has. Every "any2orca convert" without --nozzle
|
|
160
|
+
converts for it: the profile, layer heights and filament values are the U1's
|
|
161
|
+
for that size, and a creator's project made for another size is noted. The
|
|
162
|
+
U1's stock nozzles are 0.4 mm, so that's the default; Snapmaker Orca takes one
|
|
163
|
+
size for all four toolheads.
|
|
164
|
+
|
|
165
|
+
${formatOptions([
|
|
166
|
+
["(no argument) | show", "The saved size, or the default"],
|
|
167
|
+
["<size>", "Save the size your U1 has: 0.2, 0.4, 0.6 or 0.8 (mm)"],
|
|
168
|
+
["match", "Convert each file for the size its creator used, as any2orca did before 0.12"],
|
|
169
|
+
["clear", "Forget the saved size (back to 0.4)"],
|
|
170
|
+
])}
|
|
171
|
+
|
|
172
|
+
Saved in config.json in the config folder (see "any2orca telemetry --help").
|
|
173
|
+
`;
|
|
153
174
|
const TELEMETRY_HELP = `Usage: any2orca telemetry show
|
|
154
175
|
any2orca telemetry on | off
|
|
155
176
|
any2orca telemetry clear
|
|
@@ -190,6 +211,7 @@ ${formatOptions([
|
|
|
190
211
|
["--high-flow", "All four toolheads have the Snapmaker Liber High Flow Hotend. The converted file records it, so Snapmaker Orca matches your printer; colors you put on a high-flow nozzle when slicing use Snapmaker's high-flow speeds on profiles that have them (today only 0.20mm Standard, 0.4mm nozzle). Gains are largest on big prints with long, continuous paths. Ignored, with a note, on nozzle sizes with no high-flow option"],
|
|
191
212
|
["--high-flow-toolheads <list>", "Only these toolheads have the Liber hotend, numbered 1 to 4, e.g. 1 or 1,3. Otherwise the same as --high-flow; use one or the other"],
|
|
192
213
|
["--hardened-nozzle", "Your U1 has hardened steel nozzles instead of the stock stainless steel 0.4. The file records it, so Snapmaker Orca warns about abrasive filaments correctly. Only changes 0.4 nozzle conversions; Snapmaker's other sizes are hardened steel already"],
|
|
214
|
+
["--nozzle <size|match>", 'The nozzle size your U1 has, which the file is converted for: 0.2, 0.4, 0.6 or 0.8 (one size for all four toolheads, as Snapmaker Orca allows), or "match" for the size the creator used. Default: the size saved with "any2orca nozzle", else 0.4. A creator\'s size that differs is noted; a project mixing sizes gets a note naming the filaments on other sizes'],
|
|
193
215
|
["--explain", "After each file, list what the conversion changed, grouped by why: from the creator's file, kept at Snapmaker's stock value, capped for the U1, set for the firmware, layout, and your choices"],
|
|
194
216
|
["--explain-json", "Also write that, with every settings difference, to <output>.what-changed.json next to each output (format any2orca-what-changed)"],
|
|
195
217
|
["--max-unpacked <size>", "The most a project may unpack to, e.g. 4GB or 3000MB (default 2GB, at most 16GB). For a very large project; it needs about twice that much memory"],
|
|
@@ -358,6 +380,22 @@ async function runCommand(command, rest, io) {
|
|
|
358
380
|
runProfiles(await top.forRelease(values["snapmaker-orca-version"] ?? top.index.slicer.version), values.nozzle, io.out, top.releases());
|
|
359
381
|
return 0;
|
|
360
382
|
}
|
|
383
|
+
case "nozzle": {
|
|
384
|
+
const [sub, extra] = rest;
|
|
385
|
+
if (hasHelpFlag(rest)) {
|
|
386
|
+
io.out(NOZZLE_HELP);
|
|
387
|
+
return 0;
|
|
388
|
+
}
|
|
389
|
+
if (extra !== undefined)
|
|
390
|
+
throw new Error("Usage: any2orca nozzle [<size> | match | show | clear] (see: any2orca nozzle --help)");
|
|
391
|
+
if (sub === undefined || sub === "show")
|
|
392
|
+
runNozzleShow(io.env, io.out);
|
|
393
|
+
else if (sub === "clear")
|
|
394
|
+
runNozzleClear(io.env, io.out);
|
|
395
|
+
else
|
|
396
|
+
runNozzleSet(sub, io.env, io.out);
|
|
397
|
+
return 0;
|
|
398
|
+
}
|
|
361
399
|
case "telemetry": {
|
|
362
400
|
const [sub, arg] = rest;
|
|
363
401
|
if (!sub || hasHelpFlag(rest)) {
|
|
@@ -402,6 +440,8 @@ async function runCommand(command, rest, io) {
|
|
|
402
440
|
throw new Error("Use --high-flow (all four toolheads) or --high-flow-toolheads <list>, not both (see: any2orca convert --help)");
|
|
403
441
|
}
|
|
404
442
|
const highFlow = values["high-flow-toolheads"] !== undefined ? parseHighFlowToolheads(values["high-flow-toolheads"]) : Boolean(values["high-flow"]);
|
|
443
|
+
// The size the user's U1 has: --nozzle for this run, else the size saved with "any2orca nozzle", else 0.4.
|
|
444
|
+
const nozzle = values.nozzle !== undefined ? parseNozzleChoice(values.nozzle, "--nozzle") : savedNozzle(io.env);
|
|
405
445
|
if (values.quiet && !values["log-file"])
|
|
406
446
|
throw new Error("--quiet requires --log-file, otherwise errors would have nowhere to go (see: any2orca convert --help)");
|
|
407
447
|
if (values["out-dir"]) {
|
|
@@ -436,6 +476,7 @@ async function runCommand(command, rest, io) {
|
|
|
436
476
|
const logger = createLogger({ logFile: values["log-file"], quiet: Boolean(values.quiet) });
|
|
437
477
|
const options = {
|
|
438
478
|
catalog,
|
|
479
|
+
nozzle,
|
|
439
480
|
profile: values.profile,
|
|
440
481
|
...(preset ? { preset } : {}),
|
|
441
482
|
...(aboveStock ? { aboveStock } : {}),
|
package/dist/cli/surface.d.ts
CHANGED
|
@@ -83,6 +83,9 @@ export declare const CONVERT_OPTIONS: {
|
|
|
83
83
|
readonly "snapmaker-orca-version": {
|
|
84
84
|
readonly type: "string";
|
|
85
85
|
};
|
|
86
|
+
readonly nozzle: {
|
|
87
|
+
readonly type: "string";
|
|
88
|
+
};
|
|
86
89
|
readonly profile: {
|
|
87
90
|
readonly type: "string";
|
|
88
91
|
};
|
|
@@ -186,6 +189,9 @@ export declare const CLI_SURFACE: {
|
|
|
186
189
|
readonly "snapmaker-orca-version": {
|
|
187
190
|
readonly type: "string";
|
|
188
191
|
};
|
|
192
|
+
readonly nozzle: {
|
|
193
|
+
readonly type: "string";
|
|
194
|
+
};
|
|
189
195
|
readonly profile: {
|
|
190
196
|
readonly type: "string";
|
|
191
197
|
};
|
|
@@ -345,6 +351,11 @@ export declare const CLI_SURFACE: {
|
|
|
345
351
|
};
|
|
346
352
|
};
|
|
347
353
|
};
|
|
354
|
+
readonly nozzle: {
|
|
355
|
+
readonly positionals: "[<size> | match | show | clear]";
|
|
356
|
+
readonly subcommands: readonly ["show", "clear"];
|
|
357
|
+
readonly options: {};
|
|
358
|
+
};
|
|
348
359
|
readonly telemetry: {
|
|
349
360
|
readonly subcommands: readonly ["show", "on", "off", "clear", "update-check on", "update-check off"];
|
|
350
361
|
readonly options: {};
|
package/dist/cli/surface.js
CHANGED
|
@@ -32,6 +32,7 @@ export const PROFILES_OPTIONS = {
|
|
|
32
32
|
...PROFILE_OPTIONS,
|
|
33
33
|
};
|
|
34
34
|
export const CONVERT_OPTIONS = {
|
|
35
|
+
nozzle: { type: "string" },
|
|
35
36
|
profile: { type: "string" },
|
|
36
37
|
preset: { type: "string" },
|
|
37
38
|
"above-stock": { type: "string" },
|
|
@@ -68,6 +69,8 @@ export const CLI_SURFACE = {
|
|
|
68
69
|
diff: { positionals: "<a.3mf> [<b.3mf>]", options: { ...DIFF_OPTIONS, "against-stock": { type: "string", optionalValue: true } } },
|
|
69
70
|
presets: { subcommands: ["add", "list", "show", "remove", "export", "import"], options: PRESETS_OPTIONS },
|
|
70
71
|
profiles: { options: PROFILES_OPTIONS },
|
|
72
|
+
// `any2orca nozzle 0.6` saves the size; a size is a value, not a subcommand, so it isn't listed as one.
|
|
73
|
+
nozzle: { positionals: "[<size> | match | show | clear]", subcommands: ["show", "clear"], options: {} },
|
|
71
74
|
telemetry: { subcommands: ["show", "on", "off", "clear", "update-check on", "update-check off"], options: {} },
|
|
72
75
|
},
|
|
73
76
|
};
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
import { Any2orcaError } from "../errors.js";
|
|
21
21
|
import { ABOVE_STOCK_DEFAULTS, machineLimitFor } from "../engine/aboveStock.js";
|
|
22
22
|
import { FILAMENT_FLOW_VARIANT_KEYS, MAX_VOLUMETRIC_SPEED } from "../engine/applyFilamentFlowVariants.js";
|
|
23
|
+
import { bambuFilamentEntries } from "../engine/filamentVariantLayout.js";
|
|
23
24
|
import { SETTINGS_CATALOG, SETTINGS_CATALOG_SOURCE } from "./settingsCatalog.js";
|
|
24
25
|
import { isOtherPrinter, valueLayout } from "./valueLayout.js";
|
|
25
26
|
/** How a setting compares between the two sides. */
|
|
@@ -122,8 +123,12 @@ function slotCount(settings) {
|
|
|
122
123
|
}
|
|
123
124
|
return 1;
|
|
124
125
|
}
|
|
125
|
-
/**
|
|
126
|
-
|
|
126
|
+
/**
|
|
127
|
+
* The entries of each filament slot for one setting, or null if the setting isn't laid out per slot.
|
|
128
|
+
*
|
|
129
|
+
* @param bambu the side's bambuFilamentEntries, found once per side: a Bambu Studio file's filaments can have different numbers of values.
|
|
130
|
+
*/
|
|
131
|
+
function splitSlots(settings, key, slots, bambu) {
|
|
127
132
|
const value = settings[key];
|
|
128
133
|
if (!Array.isArray(value))
|
|
129
134
|
return null;
|
|
@@ -143,6 +148,8 @@ function splitSlots(settings, key, slots) {
|
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
}
|
|
151
|
+
if (bambu && list.length === bambu.length)
|
|
152
|
+
return bambu.entries.map((own) => own.map((index) => list[index]));
|
|
146
153
|
if (list.length % slots !== 0 || list.length === 0)
|
|
147
154
|
return null;
|
|
148
155
|
const per = list.length / slots;
|
|
@@ -223,6 +230,8 @@ export function diffSettings(a, b, options = {}) {
|
|
|
223
230
|
const otherPrinter = [isOtherPrinter(a.settings), isOtherPrinter(b.settings)];
|
|
224
231
|
const slotsA = slotCount(a.settings);
|
|
225
232
|
const slotsB = slotCount(b.settings);
|
|
233
|
+
const bambuA = bambuFilamentEntries(a.settings, slotsA);
|
|
234
|
+
const bambuB = bambuFilamentEntries(b.settings, slotsB);
|
|
226
235
|
const byGroup = new Map();
|
|
227
236
|
const groupFor = (group, slot) => {
|
|
228
237
|
const id = slot === undefined ? group : `${group}:${slot}`;
|
|
@@ -240,9 +249,9 @@ export function diffSettings(a, b, options = {}) {
|
|
|
240
249
|
const hasA = Object.hasOwn(a.settings, key);
|
|
241
250
|
const hasB = Object.hasOwn(b.settings, key);
|
|
242
251
|
if (group === "filament") {
|
|
243
|
-
const split = (side, has, slots) => (has ? splitSlots(side.settings, key, slots) : null);
|
|
244
|
-
const sa = split(a, hasA, slotsA);
|
|
245
|
-
const sb = split(b, hasB, slotsB);
|
|
252
|
+
const split = (side, has, slots, bambu) => (has ? splitSlots(side.settings, key, slots, bambu) : null);
|
|
253
|
+
const sa = split(a, hasA, slotsA, bambuA);
|
|
254
|
+
const sb = split(b, hasB, slotsB, bambuB);
|
|
246
255
|
if ((hasA ? sa : true) && (hasB ? sb : true)) {
|
|
247
256
|
const slots = Math.max(hasA ? slotsA : 0, hasB ? slotsB : 0);
|
|
248
257
|
for (let i = 0; i < slots; i++) {
|
|
@@ -45,4 +45,6 @@ export interface ApplyFilamentComplianceModeResult {
|
|
|
45
45
|
*/
|
|
46
46
|
export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string,
|
|
47
47
|
/** The printer's presets' settings; without them only the names change. */
|
|
48
|
-
presets?: PrinterFilamentPresets
|
|
48
|
+
presets?: PrinterFilamentPresets,
|
|
49
|
+
/** Only these slots (0-based); the rest are returned as they are and not reported. Default: every slot. */
|
|
50
|
+
only?: ReadonlySet<number>): ApplyFilamentComplianceModeResult;
|
|
@@ -25,7 +25,9 @@ const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"
|
|
|
25
25
|
*/
|
|
26
26
|
export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId,
|
|
27
27
|
/** The printer's presets' settings; without them only the names change. */
|
|
28
|
-
presets
|
|
28
|
+
presets,
|
|
29
|
+
/** Only these slots (0-based); the rest are returned as they are and not reported. Default: every slot. */
|
|
30
|
+
only) {
|
|
29
31
|
const fellBackToGeneric = new Set();
|
|
30
32
|
const unchanged = new Set();
|
|
31
33
|
const renamed = [];
|
|
@@ -36,6 +38,8 @@ presets) {
|
|
|
36
38
|
if (filamentKeyArrays?.[key])
|
|
37
39
|
arrays[key] = [...filamentKeyArrays[key]];
|
|
38
40
|
const newSlots = slots.map((slot, i) => {
|
|
41
|
+
if (only && !only.has(i))
|
|
42
|
+
return slot;
|
|
39
43
|
const filamentType = typeof slot.filament_type === "string" ? slot.filament_type : "";
|
|
40
44
|
const filamentSettingsId = typeof slot.filament_settings_id === "string" ? slot.filament_settings_id : "";
|
|
41
45
|
if (!table) {
|
|
@@ -25,8 +25,8 @@ export declare const MAX_VOLUMETRIC_SPEED: {
|
|
|
25
25
|
* Orca when it's assigned to a toolhead (`filament_volume_type`, standard
|
|
26
26
|
* until then). The standard value is what the converter already has for
|
|
27
27
|
* each slot. The high-flow value is the source's own high-flow value when
|
|
28
|
-
* the source has one (Bambu Studio stores both, named by variant
|
|
29
|
-
* Orca stores both, tagged by filament_flow_support
|
|
28
|
+
* the source has one (Bambu Studio stores both, named by variant and
|
|
29
|
+
* filament; Snapmaker Orca stores both, tagged by filament_flow_support; see
|
|
30
30
|
* filamentVariantLayout.ts), otherwise Snapmaker's stock high-flow value
|
|
31
31
|
* for settings the source doesn't carry, otherwise the standard value.
|
|
32
32
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import { detectHighFlowVariantIndex } from "./detectVariantIndex.js";
|
|
3
|
-
import { filamentVariantLayout } from "./filamentVariantLayout.js";
|
|
3
|
+
import { bambuFilamentVariantLayout, filamentVariantLayout } from "./filamentVariantLayout.js";
|
|
4
4
|
/**
|
|
5
5
|
* Filament settings that Snapmaker Orca 2.4 stores once per flow variant
|
|
6
6
|
* (standard, high flow) on a nozzle with a high-flow option. Mirrors
|
|
@@ -50,8 +50,8 @@ const cap = (value, limit) => {
|
|
|
50
50
|
* Orca when it's assigned to a toolhead (`filament_volume_type`, standard
|
|
51
51
|
* until then). The standard value is what the converter already has for
|
|
52
52
|
* each slot. The high-flow value is the source's own high-flow value when
|
|
53
|
-
* the source has one (Bambu Studio stores both, named by variant
|
|
54
|
-
* Orca stores both, tagged by filament_flow_support
|
|
53
|
+
* the source has one (Bambu Studio stores both, named by variant and
|
|
54
|
+
* filament; Snapmaker Orca stores both, tagged by filament_flow_support; see
|
|
55
55
|
* filamentVariantLayout.ts), otherwise Snapmaker's stock high-flow value
|
|
56
56
|
* for settings the source doesn't carry, otherwise the standard value.
|
|
57
57
|
*
|
|
@@ -78,7 +78,7 @@ export function applyFilamentFlowVariants(settings, source, baseline, highFlowSu
|
|
|
78
78
|
}
|
|
79
79
|
else {
|
|
80
80
|
const sourceHighFlow = detectHighFlowVariantIndex(source);
|
|
81
|
-
const layout = filamentVariantLayout(source, slotCount);
|
|
81
|
+
const layout = filamentVariantLayout(source, slotCount) ?? bambuFilamentVariantLayout(source, slotCount);
|
|
82
82
|
for (const key of FILAMENT_FLOW_VARIANT_KEYS) {
|
|
83
83
|
const standard = settings[key];
|
|
84
84
|
if (!Array.isArray(standard) || standard.length !== slotCount)
|
|
@@ -10,6 +10,8 @@ export interface AppliedFilamentPreset {
|
|
|
10
10
|
before: string;
|
|
11
11
|
after: string;
|
|
12
12
|
}>;
|
|
13
|
+
/** Only these of the preset's settings are written (a filament tuned for another nozzle size takes the calibration, not the spool facts). Absent: all. */
|
|
14
|
+
keys?: readonly string[];
|
|
13
15
|
}
|
|
14
16
|
/** One preset's settings: the values the printer's presets share, with its own over them. Undefined when there are none. */
|
|
15
17
|
export declare function presetSettingsFor(presets: PrinterFilamentPresets | undefined, name: string): Record<string, string[]> | undefined;
|
|
@@ -62,3 +64,11 @@ export declare function writeBaseGcode(settings: JsonRecord, files: Record<strin
|
|
|
62
64
|
* can't be read.
|
|
63
65
|
*/
|
|
64
66
|
export declare function listFilamentSettings(settings: JsonRecord, bases: readonly FilamentBase[], source: JsonRecord, slotCount: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* Each embedded preset holds what the project holds for the first filament of its name, in the project's layout
|
|
69
|
+
* (standard and high-flow values where the project keeps two), with that filament's parent in `inherits`. The app
|
|
70
|
+
* builds a project preset from each embedded one and compares the file's filament with it, marking the first
|
|
71
|
+
* filament modified when they differ (Preset.cpp, load_external_preset). The presets were built from the source's
|
|
72
|
+
* values, before the steps that lay out, cap or replace them, so they're brought in line last.
|
|
73
|
+
*/
|
|
74
|
+
export declare function syncEmbeddedPresets(settings: JsonRecord, files: Record<string, JsonRecord>, bases: readonly FilamentBase[], slotCount: number): void;
|
|
@@ -59,7 +59,7 @@ function writeSlot(settings, files, slot, name, values, slotCount) {
|
|
|
59
59
|
continue;
|
|
60
60
|
for (const [key, value] of Object.entries(values)) {
|
|
61
61
|
const own = cfg[key];
|
|
62
|
-
//
|
|
62
|
+
// syncEmbeddedPresets lays these out as the project holds them once every filament step has run.
|
|
63
63
|
cfg[key] = Array.isArray(own) && own.length === 1 ? [value[0]] : [...value];
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -70,10 +70,12 @@ function writeSlot(settings, files, slot, name, values, slotCount) {
|
|
|
70
70
|
* every other filament step, so nothing later overwrites it.
|
|
71
71
|
*/
|
|
72
72
|
export function writeFilamentPresets(settings, files, applied, presets, slotCount) {
|
|
73
|
-
for (const { slot, preset } of applied) {
|
|
73
|
+
for (const { slot, preset, keys } of applied) {
|
|
74
74
|
const values = presetSettingsFor(presets, preset);
|
|
75
|
-
if (values)
|
|
76
|
-
|
|
75
|
+
if (!values)
|
|
76
|
+
continue;
|
|
77
|
+
const chosen = keys ? Object.fromEntries(keys.filter((k) => Object.hasOwn(values, k)).map((k) => [k, values[k]])) : values;
|
|
78
|
+
writeSlot(settings, files, slot, preset, chosen, slotCount);
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
/**
|
|
@@ -178,3 +180,28 @@ export function listFilamentSettings(settings, bases, source, slotCount) {
|
|
|
178
180
|
if (parents.some((parent) => parent !== ""))
|
|
179
181
|
settings.inherits_group = ["", ...parents, ""];
|
|
180
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* Each embedded preset holds what the project holds for the first filament of its name, in the project's layout
|
|
185
|
+
* (standard and high-flow values where the project keeps two), with that filament's parent in `inherits`. The app
|
|
186
|
+
* builds a project preset from each embedded one and compares the file's filament with it, marking the first
|
|
187
|
+
* filament modified when they differ (Preset.cpp, load_external_preset). The presets were built from the source's
|
|
188
|
+
* values, before the steps that lay out, cap or replace them, so they're brought in line last.
|
|
189
|
+
*/
|
|
190
|
+
export function syncEmbeddedPresets(settings, files, bases, slotCount) {
|
|
191
|
+
const names = Array.isArray(settings.filament_settings_id) ? settings.filament_settings_id : [];
|
|
192
|
+
for (const cfg of Object.values(files)) {
|
|
193
|
+
const slot = names.indexOf(cfg.name);
|
|
194
|
+
if (slot < 0 || slot >= slotCount)
|
|
195
|
+
continue;
|
|
196
|
+
for (const key of Object.keys(cfg)) {
|
|
197
|
+
if (key === "filament_settings_id" || !Array.isArray(cfg[key]))
|
|
198
|
+
continue;
|
|
199
|
+
const values = slotValues(settings[key], slot, slotCount);
|
|
200
|
+
if (values)
|
|
201
|
+
cfg[key] = values;
|
|
202
|
+
}
|
|
203
|
+
const base = bases[slot];
|
|
204
|
+
if (base?.kind === "preset" && base.parent !== undefined)
|
|
205
|
+
cfg.inherits = base.parent;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
@@ -15,3 +15,31 @@ export type SupportedNozzleDiameter = KnownNozzleDiameter | (string & {});
|
|
|
15
15
|
* profile rather than guess.
|
|
16
16
|
*/
|
|
17
17
|
export declare function detectNozzleDiameter(projectSettings: JsonRecord): SupportedNozzleDiameter | null;
|
|
18
|
+
/** What a conversion can be asked to convert for: a U1 nozzle size, or the creator's own ("match"). */
|
|
19
|
+
export declare const NOZZLE_CHOICES: readonly ["0.2", "0.4", "0.6", "0.8", "match"];
|
|
20
|
+
export type KnownNozzleChoice = (typeof NOZZLE_CHOICES)[number];
|
|
21
|
+
/** One of {@link NOZZLE_CHOICES}, or a size a later catalog added. */
|
|
22
|
+
export type NozzleChoice = KnownNozzleChoice | (string & {});
|
|
23
|
+
/** The nozzle size a conversion is for unless told otherwise: the U1's stock 0.4 mm, which most U1s run. */
|
|
24
|
+
export declare const DEFAULT_NOZZLE: KnownNozzleDiameter;
|
|
25
|
+
export interface SourceNozzleSizes {
|
|
26
|
+
/** The distinct nozzle sizes the project uses, as written (e.g. "0.2", "0.4"), smallest first. */
|
|
27
|
+
sizes: string[];
|
|
28
|
+
/** The project uses more than one size (Bambu Studio's multi-diameter mode, or several sizes in its nozzle list). */
|
|
29
|
+
mixed: boolean;
|
|
30
|
+
/** Each filament's nozzle size as the file maps it, or null where the file doesn't say. */
|
|
31
|
+
filamentSizes: (string | null)[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The nozzle sizes a source project uses. A single-nozzle file has one, its
|
|
35
|
+
* `nozzle_diameter`. Two layouts carry several:
|
|
36
|
+
* - Bambu Studio's one-extruder multi-nozzle printers (the H3C's nine
|
|
37
|
+
* PrintTools) list each nozzle's size in `extruder_nozzle_diameter`, with
|
|
38
|
+
* `multi_nozzle_diameter_mode` "1" when they differ, and map each filament
|
|
39
|
+
* to a nozzle (0-based) in `filament_nozzle_map`; `nozzle_diameter` then
|
|
40
|
+
* holds only the first nozzle's size.
|
|
41
|
+
* - Multi-extruder printers (Creality's K3, with a nozzle size per toolhead)
|
|
42
|
+
* list one size per extruder in `nozzle_diameter` and map each filament
|
|
43
|
+
* to an extruder (1-based) in `filament_map`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function sourceNozzleSizes(projectSettings: JsonRecord): SourceNozzleSizes;
|
|
@@ -27,3 +27,47 @@ export function detectNozzleDiameter(projectSettings) {
|
|
|
27
27
|
}
|
|
28
28
|
return closest;
|
|
29
29
|
}
|
|
30
|
+
/** What a conversion can be asked to convert for: a U1 nozzle size, or the creator's own ("match"). */
|
|
31
|
+
export const NOZZLE_CHOICES = [...SUPPORTED_NOZZLE_DIAMETERS, "match"];
|
|
32
|
+
/** The nozzle size a conversion is for unless told otherwise: the U1's stock 0.4 mm, which most U1s run. */
|
|
33
|
+
export const DEFAULT_NOZZLE = "0.4";
|
|
34
|
+
const sizeText = (value) => {
|
|
35
|
+
const n = typeof value === "string" ? Number.parseFloat(value) : typeof value === "number" ? value : NaN;
|
|
36
|
+
return Number.isFinite(n) && n > 0 ? String(n) : null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The nozzle sizes a source project uses. A single-nozzle file has one, its
|
|
40
|
+
* `nozzle_diameter`. Two layouts carry several:
|
|
41
|
+
* - Bambu Studio's one-extruder multi-nozzle printers (the H3C's nine
|
|
42
|
+
* PrintTools) list each nozzle's size in `extruder_nozzle_diameter`, with
|
|
43
|
+
* `multi_nozzle_diameter_mode` "1" when they differ, and map each filament
|
|
44
|
+
* to a nozzle (0-based) in `filament_nozzle_map`; `nozzle_diameter` then
|
|
45
|
+
* holds only the first nozzle's size.
|
|
46
|
+
* - Multi-extruder printers (Creality's K3, with a nozzle size per toolhead)
|
|
47
|
+
* list one size per extruder in `nozzle_diameter` and map each filament
|
|
48
|
+
* to an extruder (1-based) in `filament_map`.
|
|
49
|
+
*/
|
|
50
|
+
export function sourceNozzleSizes(projectSettings) {
|
|
51
|
+
const perNozzle = Array.isArray(projectSettings.extruder_nozzle_diameter) ? projectSettings.extruder_nozzle_diameter.map(sizeText) : [];
|
|
52
|
+
const perExtruder = Array.isArray(projectSettings.nozzle_diameter) ? projectSettings.nozzle_diameter.map(sizeText) : [sizeText(projectSettings.nozzle_diameter)];
|
|
53
|
+
const nozzleList = perNozzle.some((s) => s !== null);
|
|
54
|
+
const listed = (nozzleList ? perNozzle : perExtruder).filter((s) => s !== null);
|
|
55
|
+
const sizes = [...new Set(listed)].sort((a, b) => Number(a) - Number(b));
|
|
56
|
+
const flagged = projectSettings.multi_nozzle_diameter_mode === "1" || projectSettings.multi_nozzle_diameter_mode === 1;
|
|
57
|
+
const filamentCount = Array.isArray(projectSettings.filament_colour) ? projectSettings.filament_colour.length : 0;
|
|
58
|
+
const nozzleMap = Array.isArray(projectSettings.filament_nozzle_map) ? projectSettings.filament_nozzle_map : [];
|
|
59
|
+
const extruderMap = Array.isArray(projectSettings.filament_map) ? projectSettings.filament_map : [];
|
|
60
|
+
const at = (list, i, offset) => {
|
|
61
|
+
const raw = list[i];
|
|
62
|
+
const n = typeof raw === "string" ? Number.parseInt(raw, 10) : typeof raw === "number" ? raw : NaN;
|
|
63
|
+
return Number.isInteger(n) ? n - offset : null;
|
|
64
|
+
};
|
|
65
|
+
const filamentSizes = Array.from({ length: filamentCount }, (_, i) => {
|
|
66
|
+
if (sizes.length === 1)
|
|
67
|
+
return sizes[0];
|
|
68
|
+
const table = nozzleList ? perNozzle : perExtruder;
|
|
69
|
+
const index = nozzleList ? at(nozzleMap, i, 0) : at(extruderMap, i, 1);
|
|
70
|
+
return index !== null && index >= 0 && index < table.length ? table[index] : null;
|
|
71
|
+
});
|
|
72
|
+
return { sizes, mixed: sizes.length > 1 || (flagged && sizes.length > 0), filamentSizes };
|
|
73
|
+
}
|
|
@@ -1,4 +1,17 @@
|
|
|
1
1
|
import type { JsonRecord } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* A variant name with whitespace stripped, lowercased: Bambu spells the
|
|
4
|
+
* same variant "Standard"/"HighFlow" in nozzle_volume_type but "Direct
|
|
5
|
+
* Drive High Flow" (with spaces) in the variant-name lists.
|
|
6
|
+
*/
|
|
7
|
+
export declare function variantKey(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* The flow variant a single-nozzle source was sliced with, from
|
|
10
|
+
* `nozzle_volume_type` (or `default_nozzle_volume_type`), as a
|
|
11
|
+
* {@link variantKey}; `null` when the source doesn't say. Scoped to one
|
|
12
|
+
* physical nozzle for the reason given on detectVariantIndex.
|
|
13
|
+
*/
|
|
14
|
+
export declare function activeNozzleVolumeType(bambuSettings: JsonRecord): string | null;
|
|
2
15
|
/**
|
|
3
16
|
* Determines which column of Bambu's newer per-nozzle-variant paired
|
|
4
17
|
* arrays (e.g. `outer_wall_speed: ["210", "350"]`) reflects the settings
|