any2orca 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # any2orca
2
2
 
3
+ ## 0.8.0
4
+
5
+ ### Breaking
6
+
7
+ - **`SourceVendor` has a new value, `"qidi"`.** Code that maps every value, such as a `Record<SourceVendor, string>` or an exhaustive `switch`, needs an entry for it.
8
+
9
+ ### Features
10
+
11
+ - **QIDI Studio projects are a supported source.** QIDI Studio saves in Bambu Studio's format, so its projects already converted; now they're tested (a QIDI Studio 2.7.2.73 save of the shared scene is a fixture) and named in the help, the README and the package description. The inspection's `sourceVendor` is `"qidi"` for them, read from the printer a filament preset names, since QIDI Studio writes its printer as "Q1 Pro". Converted files don't change.
12
+
13
+ ## 0.7.3
14
+
15
+ ### Output-affecting
16
+
17
+ - **A project with an empty plate converts with every plate's objects on their own plate.** The converter laid out only the plates that had objects, but the file keeps every plate, and Snapmaker Orca puts an object on the plate whose area it's in: in a project with plates 1, 3 and 4 used and plate 2 empty, the objects opened on plates 1, 2 and 3, so per-plate settings, names and pauses went with the wrong objects. Each plate now goes to the place of its own number on the U1's grid, over every plate the file has, and an empty plate stays empty; empty plates after the last used one also count toward the grid's width, as Snapmaker Orca counts them. The conversion notes each empty plate ("plate 2 has no objects in the project; it stays empty, so the other plates keep their numbers"), and the report's plate count includes them. A PrusaSlicer project with an empty bed between used ones is placed the same way, with each bed's pauses on its own plate. In a corpus of 1,568 projects, 3 move (each has an empty plate before a used one, or an empty last plate that widens the grid) and 12 change only their plate count; no other converted file changes.
18
+ - **Converting a converted file again gives no notes about "the creator", and a filament with no id of its own is written with an empty one.** A file already set up for the U1 lists every setting as changed, so the converter read its own high-flow layout back as a creator's change and said it didn't fit ("the creator changed filament_flow_support, but its values ... don't fit"); that layout is written for the U1's nozzles afterwards and is no longer read as a change. A project whose source has no filament ids (every PrusaSlicer project, and a few Bambu Studio family ones) was given one Snapmaker preset's id for its first filament and none for the rest; each filament now gets an empty id, as Snapmaker Orca writes for a filament not from its library, and relabeled filament names get their presets' own ids. In a corpus of 1,568 projects, the ids are the only change to converted files, in the 84 projects that had none; the notes changed only on re-conversion.
19
+
20
+ ### Features
21
+
22
+ - **The report says where each plate sits on the U1, and the inspection how many plates there are.** `report.plateOrigins` gives each plate's position on the U1's plate grid, in mm from plate 1, empty plates included, so a plate view can draw each plate's objects without working out the grid itself. `inspect()` gains `plateCount`, the project's plates with empty ones included; `plates` still lists the ones with objects. For a PrusaSlicer project, `sourcePlateOrigins` now has an entry for every bed up to the last used one.
23
+
24
+ ### Other
25
+
26
+ - **Converted files are written in about half the time.** The output is compressed at deflate level 3 instead of 6: on a sample of 192 real projects that wrote in 51% of the time, for files 1.7% larger. On a 1.4 GB project, compression was about 50 s of a 75 s conversion. Every file inside the converted project is unchanged; only the zip's compressed bytes differ, and Snapmaker Orca opens it the same way.
27
+ - **The web app shows empty plates.** The plate view has a tab for every plate in the project, an empty one marked as such ("Plate 2, empty"), and draws each plate's objects where the converted file puts them, using the report's plate positions; before converting, a project with an empty plate at the end is drawn on its own grid too.
28
+
3
29
  ## 0.7.2
4
30
 
5
31
  ### Other
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # any2orca
2
2
 
3
- Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio and PrusaSlicer `.3mf` projects to Snapmaker U1 / Orca format, entirely on your own machine. One package: a command-line tool, a library for Node and browsers, and a ready-made Web Worker.
3
+ Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer `.3mf` projects to Snapmaker U1 / Orca format, entirely on your own machine. One package: a command-line tool, a library for Node and browsers, and a ready-made Web Worker.
4
4
 
5
5
  Formerly bambu2orca and the `@kuzuri.ao/b2o` CLI. Same conversion, now local: no account, no API key, no quota, and nothing you convert is sent anywhere.
6
6
 
@@ -187,4 +187,4 @@ MIT.
187
187
 
188
188
  The profile data (`any2orca-profiles`) is AGPL-3.0-or-later, since it is derived from Snapmaker's AGPL presets. It is a separate package, loaded at runtime. [`NOTICE`](https://github.com/KuzuriAo/any2orca/blob/main/packages/core/NOTICE) credits the data this package includes.
189
189
 
190
- any2orca is an independent project, not affiliated with, endorsed by, or sponsored by Snapmaker, Bambu Lab, OrcaSlicer or any printer, slicer or filament maker.
190
+ any2orca is an independent project, not affiliated with, endorsed by, or sponsored by Snapmaker, Bambu Lab, Creality, Anycubic, ELEGOO, Flashforge, Prusa Research, OrcaSlicer or any other brand or vendor of printers, slicers or filament.
@@ -3,4 +3,6 @@
3
3
  * metadata in `model_settings.config`.
4
4
  *
5
5
  */
6
+ /** How many plates `model_settings.config` has, empty ones included. */
7
+ export declare function countPlates(modelSettingsText: string): number;
6
8
  export declare function parsePlateAssignments(modelSettingsText: string): Record<string, number>;
@@ -5,6 +5,13 @@ import { xmlBlocks } from "./xmlBlocks.js";
5
5
  * metadata in `model_settings.config`.
6
6
  *
7
7
  */
8
+ /** How many plates `model_settings.config` has, empty ones included. */
9
+ export function countPlates(modelSettingsText) {
10
+ let count = 0;
11
+ for (const _ of xmlBlocks(modelSettingsText, "plate"))
12
+ count++;
13
+ return count;
14
+ }
8
15
  export function parsePlateAssignments(modelSettingsText) {
9
16
  const plates = [...xmlBlocks(modelSettingsText, "plate")].map((block) => block.body);
10
17
  const assignment = {};
@@ -18,3 +18,5 @@ export declare function prepareConvertRequest(fileBytes: Uint8Array, maxUnpacked
18
18
  * passthrough config file. `extraEntries` are added last (the output stamp).
19
19
  */
20
20
  export declare function applyConvertResponse(parsed: ParsedProject, response: ConvertResponse, extraEntries?: Record<string, Uint8Array>): Uint8Array;
21
+ /** The output's deflate level; exported for the test that holds it. */
22
+ export declare const OUTPUT_DEFLATE_LEVEL = 3;
@@ -49,7 +49,7 @@ export function prepareConvertRequest(fileBytes, maxUnpackedBytes) {
49
49
  const otherFormatSettings = zipEntries[OTHER_FORMAT_SETTINGS_PATH];
50
50
  if (otherFormatSettings) {
51
51
  const slicer = otherFormatSlicer(otherFormatSettings);
52
- throw new Any2orcaError("unsupported_slicer", `This project was saved by ${slicer}, and only projects from Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio and PrusaSlicer can be converted.`, { slicer });
52
+ throw new Any2orcaError("unsupported_slicer", `This project was saved by ${slicer}, and only projects from Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer can be converted.`, { slicer });
53
53
  }
54
54
  // A zip that isn't a 3MF at all (no model part, no print settings): a bundle of STL files, say.
55
55
  if (!zipEntries[TOP_MODEL_PATH]) {
@@ -101,11 +101,13 @@ export function applyConvertResponse(parsed, response, extraEntries = {}) {
101
101
  // record when, or in which time zone, it was converted. Zip times are local
102
102
  // clock fields, so a Date built from local fields encodes identically everywhere.
103
103
  //
104
- // Level 6, not 9: on a 100 MB project, level 9 spent three fifths of the whole
105
- // conversion recompressing mesh files the conversion never changes, for files
106
- // a few percent smaller. Level 6 halves the time. Every entry's content is the
107
- // same at any level; only the zip's bytes differ.
104
+ // Level 3: on a sample of 192 real projects, it wrote in 51% of level 6's time for
105
+ // files 1.7% larger (level 2: 46% and 2.6%; level 1: 41% and 4.4%), so going lower
106
+ // buys little time for more size. A 1.4 GB project spent about 50 s of a 75 s
107
+ // conversion compressing at level 6. Every entry's content is the same at any
108
+ // level; only the zip's bytes differ, and Snapmaker Orca opens the files the same way.
108
109
  return zipSync(outputEntries, { level: OUTPUT_DEFLATE_LEVEL, mtime: FIXED_ENTRY_TIME });
109
110
  }
110
- const OUTPUT_DEFLATE_LEVEL = 6;
111
+ /** The output's deflate level; exported for the test that holds it. */
112
+ export const OUTPUT_DEFLATE_LEVEL = 3;
111
113
  const FIXED_ENTRY_TIME = new Date(2000, 0, 1, 0, 0, 0);
package/dist/cli/main.js CHANGED
@@ -45,7 +45,7 @@ function wrapText(text, width) {
45
45
  lines.push(line);
46
46
  return lines;
47
47
  }
48
- const TOP_LEVEL_HELP = `any2orca ${VERSION}: convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio and PrusaSlicer .3mf projects to Snapmaker U1 / Orca format, entirely on this machine.
48
+ const TOP_LEVEL_HELP = `any2orca ${VERSION}: convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer .3mf projects to Snapmaker U1 / Orca format, entirely on this machine.
49
49
 
50
50
  Usage: any2orca <command> [options]
51
51
 
@@ -37,6 +37,11 @@ export declare const MAX_VOLUMETRIC_SPEED: {
37
37
  *
38
38
  * @param fromSource filament keys whose per-slot values came from the source.
39
39
  */
40
+ /**
41
+ * The settings this step always writes for the target nozzle, whatever the source says: they describe the U1's own
42
+ * flow layout, not a creator's choice, so nothing upstream treats the source's values for them as a change to carry.
43
+ */
44
+ export declare const FLOW_LAYOUT_KEYS: ReadonlySet<string>;
40
45
  export declare function applyFilamentFlowVariants(settings: JsonRecord, source: JsonRecord, baseline: JsonRecord, highFlowSupported: boolean, fromSource: ReadonlySet<string>, slotCount: number, warnings: string[], options?: {
41
46
  capVolumetricSpeed?: boolean;
42
47
  }): void;
@@ -62,6 +62,11 @@ const cap = (value, limit) => {
62
62
  *
63
63
  * @param fromSource filament keys whose per-slot values came from the source.
64
64
  */
65
+ /**
66
+ * The settings this step always writes for the target nozzle, whatever the source says: they describe the U1's own
67
+ * flow layout, not a creator's choice, so nothing upstream treats the source's values for them as a change to carry.
68
+ */
69
+ export const FLOW_LAYOUT_KEYS = new Set(["filament_flow_support", "filament_flow_step_size", "filament_volume_type"]);
65
70
  export function applyFilamentFlowVariants(settings, source, baseline, highFlowSupported, fromSource, slotCount, warnings, options = {}) {
66
71
  if (slotCount < 1)
67
72
  return;
@@ -1,4 +1,5 @@
1
1
  // SPDX-License-Identifier: MIT
2
+ import { FLOW_LAYOUT_KEYS } from "./applyFilamentFlowVariants.js";
2
3
  import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
3
4
  import { coerceValue } from "./coerceValue.js";
4
5
  import { collapseNozzleVariants } from "./collapseNozzleVariants.js";
@@ -58,6 +59,9 @@ export function buildProjectSettings(baselineSettings, bambuSettings, filamentKe
58
59
  .filter((k) => !blocklist.has(k) && !minComparisonKeys.has(k) && !alwaysTransferKeys.has(k))
59
60
  // Filament arrays and flush volumes are overlaid as a whole below, sized to the project's filaments.
60
61
  .filter((k) => !(filamentKeyArrays && Object.hasOwn(filamentKeyArrays, k)) && !k.startsWith("flush_volumes_"))
62
+ // The flow layout is written for the U1's nozzles afterwards (applyFilamentFlowVariants); a file already set up
63
+ // for the U1 lists it as changed, which isn't the creator's doing.
64
+ .filter((k) => !FLOW_LAYOUT_KEYS.has(k))
61
65
  .filter((k) => bambuCustomizedKeys.has(k))
62
66
  .sort();
63
67
  const newSettings = { ...baselineSettings };
@@ -1,6 +1,8 @@
1
1
  import type { ConvertObject } from "../schema.js";
2
2
  export interface ComputeShiftsResult {
3
3
  shifts: Record<string, [number, number]>;
4
+ /** Each plate's position on the U1's grid, from plate 1's, keyed by plate number, empty plates included. */
5
+ plateOrigins: Record<string, [number, number]>;
4
6
  warnings: string[];
5
7
  }
6
8
  /**
@@ -9,4 +11,6 @@ export interface ComputeShiftsResult {
9
11
  * `objects[]`) instead of deriving it from mesh geometry, so the mesh is
10
12
  * read only once, when the file is opened.
11
13
  */
12
- export declare function computeShifts(objects: readonly ConvertObject[], orcaPrintableArea: readonly string[], bambuClearanceRadius: number | null, orcaClearanceRadius: number | null): ComputeShiftsResult;
14
+ export declare function computeShifts(objects: readonly ConvertObject[], orcaPrintableArea: readonly string[], bambuClearanceRadius: number | null, orcaClearanceRadius: number | null,
15
+ /** The project's plates, empty ones included (the request's plateCount); absent, the highest plate an object is on. */
16
+ plateCount?: number): ComputeShiftsResult;
@@ -33,7 +33,9 @@ function aabbGap(a, b) {
33
33
  * `objects[]`) instead of deriving it from mesh geometry, so the mesh is
34
34
  * read only once, when the file is opened.
35
35
  */
36
- export function computeShifts(objects, orcaPrintableArea, bambuClearanceRadius, orcaClearanceRadius) {
36
+ export function computeShifts(objects, orcaPrintableArea, bambuClearanceRadius, orcaClearanceRadius,
37
+ /** The project's plates, empty ones included (the request's plateCount); absent, the highest plate an object is on. */
38
+ plateCount) {
37
39
  const warnings = [];
38
40
  const objectById = new Map(objects.map((o) => [o.id, o]));
39
41
  // Group object ids by plate; objects with no plate metadata each become
@@ -94,7 +96,14 @@ export function computeShifts(objects, orcaPrintableArea, bambuClearanceRadius,
94
96
  // own pitch from its OWN bed size, not the source file's spacing (Orca's
95
97
  // own "Center" operation on the U1's 270mm bed uses 270*1.2 = 324mm
96
98
  // spacing, confirmed against real before/after coordinates).
97
- const cols = plateKeys.length > 0 ? Math.max(1, Math.ceil(Math.sqrt(plateKeys.length))) : 1;
99
+ //
100
+ // The grid is over every plate the file has, empty ones included, and a plate
101
+ // sits at the cell of its own number: Snapmaker Orca puts an object on the
102
+ // plate whose area it's in, so packing only the used plates would move every
103
+ // plate after an empty one onto the one before it (a real project: plates 1,
104
+ // 3 and 4 used, plate 2 empty, opened as 1, 2 and 3).
105
+ const plateSlots = Math.max(1, plateCount ?? 0, ...plateKeys);
106
+ const cols = Math.max(1, Math.ceil(Math.sqrt(plateSlots)));
98
107
  const orcaBed = parseBedCorners(orcaPrintableArea);
99
108
  const orcaBedW = orcaBed.maxX - orcaBed.minX;
100
109
  const orcaBedH = orcaBed.maxY - orcaBed.minY;
@@ -123,11 +132,26 @@ export function computeShifts(objects, orcaPrintableArea, bambuClearanceRadius,
123
132
  shifts[oid] = [dx, dy];
124
133
  }
125
134
  };
126
- plateKeys.forEach((key, plateIdx) => {
127
- const col = plateIdx % cols;
128
- const row = Math.floor(plateIdx / cols);
129
- applyGroupShift(key, plateGroups.get(key), [orcaCx + col * pitchX, orcaCy + row * pitchY]);
130
- });
135
+ const cellOf = (plate) => {
136
+ const index = plate - 1;
137
+ return [(index % cols) * pitchX || 0, Math.floor(index / cols) * pitchY || 0];
138
+ };
139
+ const plateOrigins = {};
140
+ for (let plate = 1; plate <= plateSlots; plate++)
141
+ plateOrigins[String(plate)] = cellOf(plate);
142
+ for (const key of plateKeys) {
143
+ const [dx, dy] = cellOf(key);
144
+ applyGroupShift(key, plateGroups.get(key), [orcaCx + dx, orcaCy + dy]);
145
+ }
146
+ if (plateSlots > 1) {
147
+ for (let plate = 1; plate <= plateSlots; plate++) {
148
+ // An object with no plate is placed on plate 1 (below), so plate 1 isn't empty when there is one.
149
+ if (plate === 1 && unassignedIds.length > 0)
150
+ continue;
151
+ if (!plateGroups.has(plate))
152
+ warnings.push(` WARN: plate ${plate} has no objects in the project; it stays empty, so the other plates keep their numbers.`);
153
+ }
154
+ }
131
155
  for (const oid of unassignedIds) {
132
156
  applyGroupShift(`__unassigned_${oid}`, [oid], [orcaCx, orcaCy]);
133
157
  }
@@ -335,5 +359,5 @@ export function computeShifts(objects, orcaPrintableArea, bambuClearanceRadius,
335
359
  `Review spacing on this plate before printing.`);
336
360
  }
337
361
  }
338
- return { shifts, warnings };
362
+ return { shifts, plateOrigins, warnings };
339
363
  }
@@ -58,7 +58,9 @@ export function extractFilamentSlots(bambuSettings, filamentTemplateKeys, extraP
58
58
  ? bval.slice(0, filamentCount)
59
59
  : null;
60
60
  if (reshaped === null) {
61
- note(stockUsed, bval.length, key);
61
+ // An id list that doesn't fit is left out like a missing one (below), not replaced by the stock list.
62
+ if (key !== "filament_ids")
63
+ note(stockUsed, bval.length, key);
62
64
  continue;
63
65
  }
64
66
  if (bval.length > filamentCount && !(Array.isArray(variantNames) && variantNames.length === bval.length)) {
@@ -66,6 +68,12 @@ export function extractFilamentSlots(bambuSettings, filamentTemplateKeys, extraP
66
68
  }
67
69
  perProjectKeyArrays[key] = reshaped;
68
70
  }
71
+ // A filament's id names a preset in the slicer's own library. A source with no usable ids (PrusaSlicer has none)
72
+ // gets an empty one per filament, as Snapmaker Orca writes for a filament not from its library, instead of the
73
+ // stock list: one Snapmaker preset's id for a single filament, which claims an identity none of these have and
74
+ // leaves the list shorter than the filaments. The filament names setting fills in real ids where it renames.
75
+ if (keysToPull.includes("filament_ids") && !perProjectKeyArrays.filament_ids)
76
+ perProjectKeyArrays.filament_ids = Array.from({ length: filamentCount }, () => "");
69
77
  for (const [length, keys] of stockUsed) {
70
78
  warnings.push(keys.length === 1
71
79
  ? ` WARN: ${keys[0]} has ${length} values for ${filamentCount} filaments in the source file, so Snapmaker's stock value is used for it.`
@@ -199,7 +199,7 @@ export function runConvertPipeline(profile, request, application, options = {})
199
199
  const bambuClearanceRadius = typeof bambuClearanceRadiusRaw === "string" || typeof bambuClearanceRadiusRaw === "number"
200
200
  ? Number(bambuClearanceRadiusRaw)
201
201
  : null;
202
- const { shifts, warnings: shiftWarnings } = computeShifts(request.objects, printer.printableArea, Number.isFinite(bambuClearanceRadius) ? bambuClearanceRadius : null, printer.extruderClearanceRadius);
202
+ const { shifts, plateOrigins, warnings: shiftWarnings } = computeShifts(request.objects, printer.printableArea, Number.isFinite(bambuClearanceRadius) ? bambuClearanceRadius : null, printer.extruderClearanceRadius, request.plateCount);
203
203
  warnings.push(...shiftWarnings);
204
204
  addShiftItems(tracker, request.objects, shifts);
205
205
  const configFiles = { ...filamentFiles };
@@ -216,6 +216,7 @@ export function runConvertPipeline(profile, request, application, options = {})
216
216
  projectSettings: newSettings,
217
217
  configFiles,
218
218
  shifts,
219
+ plateOrigins,
219
220
  application,
220
221
  ...(filamentComplianceFallback ? { filamentComplianceFallback } : {}),
221
222
  ...(filamentComplianceUnchanged ? { filamentComplianceUnchanged } : {}),
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * any2orca: convert Bambu Studio, Creality Print, Anycubic Slicer Next,
3
- * ElegooSlicer, Flash Studio and PrusaSlicer 3MF projects for the Snapmaker U1
3
+ * ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer 3MF projects for the Snapmaker U1
4
4
  * (Snapmaker Orca), entirely in the caller's own process. The library makes no network
5
5
  * requests of its own; profile data comes from a {@link ProfileSource} the
6
6
  * caller provides.
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  /**
3
3
  * any2orca: convert Bambu Studio, Creality Print, Anycubic Slicer Next,
4
- * ElegooSlicer, Flash Studio and PrusaSlicer 3MF projects for the Snapmaker U1
4
+ * ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer 3MF projects for the Snapmaker U1
5
5
  * (Snapmaker Orca), entirely in the caller's own process. The library makes no network
6
6
  * requests of its own; profile data comes from a {@link ProfileSource} the
7
7
  * caller provides.
package/dist/inspect.d.ts CHANGED
@@ -9,7 +9,7 @@ import { type FilamentColorMatch } from "./archive/lookupFilamentColorName.js";
9
9
  import { type SupportedNozzleDiameter } from "./engine/detectNozzleDiameter.js";
10
10
  import type { ConvertObject } from "./schema.js";
11
11
  /** The printer maker a source file was set up for, from its `printer_model`. */
12
- export type SourceVendor = "bambu" | "creality" | "anycubic" | "snapmaker" | "elegoo" | "prusa" | "flashforge" | "other";
12
+ export type SourceVendor = "bambu" | "creality" | "anycubic" | "snapmaker" | "elegoo" | "prusa" | "flashforge" | "qidi" | "other";
13
13
  export interface FilamentSlotInfo {
14
14
  /** 1-based slot number, as slicers show it. */
15
15
  slot: number;
@@ -25,6 +25,11 @@ export interface FilamentSlotInfo {
25
25
  export interface Inspection {
26
26
  /** Distinct plate numbers that have objects, ascending. */
27
27
  plates: number[];
28
+ /**
29
+ * How many plates the project has, empty ones included (a plate with no objects keeps its number). Always set by
30
+ * `inspect()`; optional so code that builds an Inspection itself (a test's mock) needn't.
31
+ */
32
+ plateCount?: number;
28
33
  /** Top-level objects with their footprint on the source bed (bbox, or fallbackXy when bbox is null). */
29
34
  objects: ConvertObject[];
30
35
  filaments: FilamentSlotInfo[];
@@ -59,6 +64,6 @@ export interface Inspection {
59
64
  */
60
65
  unpackedBytes: number;
61
66
  }
62
- export declare function detectSourceVendor(printerModel: string | null, sourcePresetName?: string | null, printerNotes?: string | null, printerPresetName?: string | null): SourceVendor;
67
+ export declare function detectSourceVendor(printerModel: string | null, sourcePresetName?: string | null, printerNotes?: string | null, printerPresetName?: string | null, filamentPresetName?: string | null): SourceVendor;
63
68
  /** Builds an {@link Inspection} from a parsed project's settings and objects. */
64
- export declare function inspectProject(projectSettings: Record<string, unknown>, objects: ConvertObject[], warnings: readonly string[], unpackedBytes: number, sourcePlateOrigins?: Readonly<Record<number, readonly [number, number]>>): Inspection;
69
+ export declare function inspectProject(projectSettings: Record<string, unknown>, objects: ConvertObject[], warnings: readonly string[], unpackedBytes: number, sourcePlateOrigins?: Readonly<Record<number, readonly [number, number]>>, plateCount?: number): Inspection;
package/dist/inspect.js CHANGED
@@ -18,6 +18,7 @@ const VENDOR_PATTERNS = [
18
18
  { vendor: "elegoo", pattern: /^elegoo\b/i },
19
19
  { vendor: "prusa", pattern: /^(original\s+)?prusa\b/i },
20
20
  { vendor: "flashforge", pattern: /^flashforge\b/i },
21
+ { vendor: "qidi", pattern: /^qidi\b/i },
21
22
  ];
22
23
  const MAX_DISPLAY_STRING = 500;
23
24
  function asDisplayString(value) {
@@ -42,18 +43,21 @@ function guessMaterial(presetName) {
42
43
  /**
43
44
  * The source printer's maker, from `printer_model` (e.g. "Creality K2 Plus"),
44
45
  * falling back to the printer named after "@" in the process preset (e.g.
45
- * "0.20mm Standard @BBL X1C"). Not the 3MF's Application tag: Anycubic
46
- * Slicer Next writes "BambuStudio" there.
46
+ * "0.20mm Standard @BBL X1C"), then in the first filament preset (QIDI
47
+ * Studio's printer model and process preset say only "Q1 Pro"; its filament
48
+ * presets say "@Qidi Q1 Pro 0.4 nozzle"). Not the 3MF's Application tag:
49
+ * Anycubic Slicer Next writes "BambuStudio" there.
47
50
  */
48
51
  /** PrusaSlicer's printer profiles name their maker in `printer_notes` ("PRINTER_VENDOR_PRUSA3D"), where the model name doesn't. */
49
52
  const NOTES_VENDORS = { PRUSA3D: "prusa", CREALITY: "creality", ANYCUBIC: "anycubic", ELEGOO: "elegoo", FLASHFORGE: "flashforge", SNAPMAKER: "snapmaker", BBL: "bambu" };
50
- export function detectSourceVendor(printerModel, sourcePresetName = null, printerNotes = null, printerPresetName = null) {
53
+ export function detectSourceVendor(printerModel, sourcePresetName = null, printerNotes = null, printerPresetName = null, filamentPresetName = null) {
51
54
  const presetPrinter = sourcePresetName?.split("@")[1]?.trim() ?? null;
55
+ const filamentPrinter = filamentPresetName?.split("@")[1]?.trim() ?? null;
52
56
  const notesVendor = /\bPRINTER_VENDOR_([A-Z0-9]{1,20})\b/.exec(printerNotes ?? "")?.[1];
53
57
  if (notesVendor && Object.hasOwn(NOTES_VENDORS, notesVendor))
54
58
  return NOTES_VENDORS[notesVendor];
55
59
  // The printer preset's name last: PrusaSlicer's `printer_model` is a code ("COREONE"), its preset name says "Prusa CORE One".
56
- for (const candidate of [printerModel, presetPrinter, printerPresetName]) {
60
+ for (const candidate of [printerModel, presetPrinter, printerPresetName, filamentPrinter]) {
57
61
  if (!candidate)
58
62
  continue;
59
63
  const match = VENDOR_PATTERNS.find(({ pattern }) => pattern.test(candidate));
@@ -63,7 +67,7 @@ export function detectSourceVendor(printerModel, sourcePresetName = null, printe
63
67
  return "other";
64
68
  }
65
69
  /** Builds an {@link Inspection} from a parsed project's settings and objects. */
66
- export function inspectProject(projectSettings, objects, warnings, unpackedBytes, sourcePlateOrigins) {
70
+ export function inspectProject(projectSettings, objects, warnings, unpackedBytes, sourcePlateOrigins, plateCount) {
67
71
  const colors = toStringArray(projectSettings.filament_colour);
68
72
  const types = toStringArray(projectSettings.filament_type);
69
73
  const names = toStringArray(projectSettings.filament_settings_id);
@@ -90,6 +94,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
90
94
  const printableArea = projectSettings.printable_area;
91
95
  return {
92
96
  plates,
97
+ plateCount: Math.max(1, plateCount ?? 0, ...plates),
93
98
  objects: objects.map((o) => ({ ...o })),
94
99
  filaments,
95
100
  nozzleDiameter: asDisplayString(rawNozzle),
@@ -98,7 +103,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
98
103
  sourcePresetName,
99
104
  tierName: typeof projectSettings.print_settings_id === "string" ? parseTierName(projectSettings.print_settings_id) : null,
100
105
  printerModel,
101
- sourceVendor: detectSourceVendor(printerModel, sourcePresetName, typeof projectSettings.printer_notes === "string" ? projectSettings.printer_notes.slice(0, 4000) : null, asDisplayString(projectSettings.printer_settings_id)),
106
+ sourceVendor: detectSourceVendor(printerModel, sourcePresetName, typeof projectSettings.printer_notes === "string" ? projectSettings.printer_notes.slice(0, 4000) : null, asDisplayString(projectSettings.printer_settings_id), names[0]?.slice(0, 200) ?? null),
102
107
  slicerVersion: asDisplayString(projectSettings.version),
103
108
  sourcePrintableArea: Array.isArray(printableArea) && printableArea.length <= 64 && printableArea.every((p) => typeof p === "string")
104
109
  ? printableArea.slice()
@@ -106,7 +111,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
106
111
  warnings: [...warnings],
107
112
  unpackedBytes,
108
113
  ...(sourcePlateOrigins
109
- ? { sourcePlateOrigins: Object.fromEntries(plates.filter((p) => Object.hasOwn(sourcePlateOrigins, p)).map((p) => [p, [sourcePlateOrigins[p][0], sourcePlateOrigins[p][1]]])) }
114
+ ? { sourcePlateOrigins: Object.fromEntries(Object.entries(sourcePlateOrigins).slice(0, 1000).map(([p, origin]) => [Number(p), [origin[0], origin[1]]])) }
110
115
  : {}),
111
116
  };
112
117
  }
package/dist/project.d.ts CHANGED
@@ -111,6 +111,12 @@ export interface ConvertReport {
111
111
  filamentComplianceUnchanged?: string[];
112
112
  /** How far each object was moved, by object id. */
113
113
  shifts: Shifts;
114
+ /**
115
+ * Where each plate sits on the U1's plate grid, in mm from plate 1, keyed by plate number, empty plates included:
116
+ * subtract it from an object's moved position to draw the object on its own plate.
117
+ */
118
+ plateOrigins?: Record<number, [number, number]>;
119
+ /** The plates in the converted file, empty ones included. */
114
120
  plates: number;
115
121
  objects: number;
116
122
  filamentSlots: number;
package/dist/project.js CHANGED
@@ -191,7 +191,7 @@ export class Project {
191
191
  return structuredClone(this.request.projectSettings);
192
192
  }
193
193
  inspect() {
194
- return inspectProject(this.request.projectSettings, this.request.objects, this.parsed.warnings, this.parsed.unpackedBytes, this.parsed.sourcePlateOrigins);
194
+ return inspectProject(this.request.projectSettings, this.request.objects, this.parsed.warnings, this.parsed.unpackedBytes, this.parsed.sourcePlateOrigins, this.request.plateCount);
195
195
  }
196
196
  /** The profile auto-matching would pick for this file. */
197
197
  matchProfile(profiles) {
@@ -319,7 +319,8 @@ export class Project {
319
319
  ...(response.filamentComplianceFallback ? { filamentComplianceFallback: response.filamentComplianceFallback } : {}),
320
320
  ...(response.filamentComplianceUnchanged ? { filamentComplianceUnchanged: response.filamentComplianceUnchanged } : {}),
321
321
  shifts: response.shifts,
322
- plates: Math.max(1, inspection.plates.length),
322
+ ...(response.plateOrigins ? { plateOrigins: Object.fromEntries(Object.entries(response.plateOrigins).map(([plate, origin]) => [Number(plate), origin])) } : {}),
323
+ plates: Math.max(1, this.request.plateCount ?? 0, ...inspection.plates),
323
324
  objects: inspection.objects.length,
324
325
  filamentSlots: inspection.filaments.length,
325
326
  filaments,
package/dist/schema.d.ts CHANGED
@@ -45,6 +45,7 @@ export declare const ConvertRequestSchema: z.ZodObject<{
45
45
  bbox: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
46
46
  fallbackXy: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
47
47
  }, z.core.$strip>>;
48
+ plateCount: z.ZodOptional<z.ZodNumber>;
48
49
  profileId: z.ZodOptional<z.ZodString>;
49
50
  filamentComplianceMode: z.ZodOptional<z.ZodEnum<{
50
51
  generic: "generic";
@@ -84,6 +85,7 @@ export declare const ConvertResponseSchema: z.ZodObject<{
84
85
  projectSettings: z.ZodRecord<z.ZodString, z.ZodUnknown>;
85
86
  configFiles: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
86
87
  shifts: z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
88
+ plateOrigins: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>>;
87
89
  application: z.ZodString;
88
90
  profileMatch: z.ZodOptional<z.ZodObject<{
89
91
  profileId: z.ZodString;
package/dist/schema.js CHANGED
@@ -36,6 +36,11 @@ export const HighFlowHotendsSchema = z.union([z.boolean(), z.array(z.boolean()).
36
36
  export const ConvertRequestSchema = z.object({
37
37
  projectSettings: ProjectSettingsSchema,
38
38
  objects: z.array(ConvertObjectSchema).max(MAX_OBJECTS),
39
+ /**
40
+ * How many plates the project has, empty ones included: the slicer lays plates out on a grid by their number over
41
+ * all of them, so an empty plate keeps its place. Absent: the highest plate an object is on.
42
+ */
43
+ plateCount: z.number().int().min(1).max(MAX_OBJECTS).optional(),
39
44
  profileId: z.string().optional(),
40
45
  /**
41
46
  * Relabels each filament's identity (name/filament_settings_id) to a real
@@ -75,6 +80,8 @@ export const ConvertResponseSchema = z.object({
75
80
  projectSettings: ProjectSettingsSchema,
76
81
  configFiles: ConfigFilesSchema,
77
82
  shifts: ShiftsSchema,
83
+ /** Each plate's position on the U1's plate grid, from plate 1's, in mm, keyed by plate number, empty plates included. */
84
+ plateOrigins: z.record(z.string(), z.tuple([z.number(), z.number()])).optional(),
78
85
  /** What the target slicer writes as its Application at the pinned release (e.g. "Snapmaker_Orca-2.4.0"); replaces the source's. */
79
86
  application: z.string().regex(APPLICATION_VALUE),
80
87
  /** Present when the profile was auto-matched rather than chosen. */
@@ -1,7 +1,7 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  /**
3
3
  * The reader for Bambu Studio and the slicers built on it (Creality Print,
4
- * Anycubic Slicer Next, ElegooSlicer, Flash Studio): a project's settings are
4
+ * Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio): a project's settings are
5
5
  * JSON in `Metadata/project_settings.config`, per-object settings and plates
6
6
  * in `Metadata/model_settings.config`, the build in `3D/3dmodel.model`.
7
7
  */
@@ -11,7 +11,7 @@ import { objectWorldBboxXY } from "../archive/objectWorldBboxXY.js";
11
11
  import { parseItemPositions } from "../archive/parseItemPositions.js";
12
12
  import { MODEL_SETTINGS_PATH, PROJECT_SETTINGS_PATH, TOP_MODEL_PATH } from "../archive/paths.js";
13
13
  import { parseObjectMetadata } from "../archive/parseObjectMetadata.js";
14
- import { parsePlateAssignments } from "../archive/parsePlateAssignments.js";
14
+ import { countPlates, parsePlateAssignments } from "../archive/parsePlateAssignments.js";
15
15
  import { tolerantJsonParse } from "../archive/tolerantJsonParse.js";
16
16
  const utf8Decoder = new TextDecoder("utf-8");
17
17
  /** The largest main model file read as text: the engine's longest string is about 512 MB, and UTF-8 never takes fewer bytes than characters. */
@@ -56,6 +56,7 @@ export const bambuFamilyReader = {
56
56
  throw new Any2orcaError("invalid_project", `This project has ${itemCount} objects, more than the ${MAX_OBJECTS} a conversion supports.`);
57
57
  }
58
58
  const plateAssignments = modelSettingsText ? parsePlateAssignments(modelSettingsText) : {};
59
+ const plateCount = modelSettingsText ? Math.min(countPlates(modelSettingsText), MAX_OBJECTS) : 0;
59
60
  const objectMetadata = parseObjectMetadata(topModelText, modelSettingsText);
60
61
  const partFileCache = new Map();
61
62
  const objects = Object.entries(itemPositions).map(([id, fallbackXy]) => {
@@ -74,7 +75,7 @@ export const bambuFamilyReader = {
74
75
  return {
75
76
  source: "bambu-family",
76
77
  zipEntries,
77
- request: { projectSettings: projectSettings, objects },
78
+ request: { projectSettings: projectSettings, objects, ...(plateCount > 0 ? { plateCount } : {}) },
78
79
  warnings,
79
80
  unpackedBytes,
80
81
  };
@@ -344,9 +344,11 @@ export const prusaReader = {
344
344
  plateOf.set(Number(id), plate);
345
345
  return { id, ...(name ? { name } : {}), plate, ...(bbox ? { bbox } : { bbox: null, fallbackXy }) };
346
346
  });
347
- const plateCount = new Set(plateOf.values()).size;
347
+ // Plates up to the highest bed used, an empty bed kept as an empty plate, as PrusaSlicer keeps it, so each bed's
348
+ // pauses and its objects stay together on the plate of its number.
349
+ const plateCount = Math.max(1, ...plateOf.values());
348
350
  // Where each plate's bed sits in the project, for drawing an object on its own plate: PrusaSlicer's grid, not Bambu Studio's.
349
- const sourcePlateOrigins = bed ? Object.fromEntries([...new Set(plateOf.values())].map((plate) => [plate, bedTranslation(plate - 1, bed)])) : undefined;
351
+ const sourcePlateOrigins = bed ? Object.fromEntries(Array.from({ length: plateCount }, (_, i) => [i + 1, bedTranslation(i, bed)])) : undefined;
350
352
  if (plateCount > 1)
351
353
  warnings.push(` note: the project's ${plateCount} beds become ${plateCount} plates.`);
352
354
  // Objects the model file places, in its order; the per-object config may name objects that aren't placed.
@@ -397,7 +399,7 @@ export const prusaReader = {
397
399
  vendorKeyword: /\bPRINTER_VENDOR_([A-Z0-9]{1,20})\b/.exec(printerNotes)?.[1] ?? null,
398
400
  },
399
401
  zipEntries: entries,
400
- request: { projectSettings: converted.settings, objects },
402
+ request: { projectSettings: converted.settings, objects, ...(plateCount > 1 ? { plateCount } : {}) },
401
403
  warnings,
402
404
  unpackedBytes,
403
405
  ...(sourcePlateOrigins ? { sourcePlateOrigins } : {}),
@@ -40,6 +40,7 @@ export declare const StatsEventSchema: z.ZodObject<{
40
40
  anycubic: "anycubic";
41
41
  elegoo: "elegoo";
42
42
  prusa: "prusa";
43
+ qidi: "qidi";
43
44
  }>;
44
45
  ref: z.ZodOptional<z.ZodString>;
45
46
  day: z.ZodString;
package/dist/telemetry.js CHANGED
@@ -35,7 +35,7 @@ export const StatsEventSchema = z
35
35
  objects: z.number().int().min(0).max(10_000).describe("number of objects"),
36
36
  filamentSlots: z.number().int().min(0).max(1_000).describe("number of filament slots"),
37
37
  sourceVendor: z
38
- .enum(["bambu", "creality", "anycubic", "snapmaker", "elegoo", "prusa", "flashforge", "other"])
38
+ .enum(["bambu", "creality", "anycubic", "snapmaker", "elegoo", "prusa", "flashforge", "qidi", "other"])
39
39
  .describe("the printer maker the source file was set up for"),
40
40
  ref: z.string().regex(REF_PATTERN).optional().describe("which site sent you here, if it said so (a short slug, never free text)"),
41
41
  day: z
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.7.2";
1
+ export declare const VERSION = "0.8.0";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Written by scripts/sync-version.mjs from package.json; a test checks they match.
3
- export const VERSION = "0.7.2";
3
+ export const VERSION = "0.8.0";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "any2orca",
3
- "version": "0.7.2",
4
- "description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio and PrusaSlicer 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
3
+ "version": "0.8.0",
4
+ "description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
5
5
  "keywords": [
6
6
  "3mf",
7
7
  "snapmaker",