any2orca 0.7.2 → 0.7.3

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,21 @@
1
1
  # any2orca
2
2
 
3
+ ## 0.7.3
4
+
5
+ ### Output-affecting
6
+
7
+ - **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.
8
+ - **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.
9
+
10
+ ### Features
11
+
12
+ - **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.
13
+
14
+ ### Other
15
+
16
+ - **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.
17
+ - **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.
18
+
3
19
  ## 0.7.2
4
20
 
5
21
  ### Other
@@ -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;
@@ -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);
@@ -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/inspect.d.ts CHANGED
@@ -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[];
@@ -61,4 +66,4 @@ export interface Inspection {
61
66
  }
62
67
  export declare function detectSourceVendor(printerModel: string | null, sourcePresetName?: string | null, printerNotes?: string | null, printerPresetName?: 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
@@ -63,7 +63,7 @@ export function detectSourceVendor(printerModel, sourcePresetName = null, printe
63
63
  return "other";
64
64
  }
65
65
  /** Builds an {@link Inspection} from a parsed project's settings and objects. */
66
- export function inspectProject(projectSettings, objects, warnings, unpackedBytes, sourcePlateOrigins) {
66
+ export function inspectProject(projectSettings, objects, warnings, unpackedBytes, sourcePlateOrigins, plateCount) {
67
67
  const colors = toStringArray(projectSettings.filament_colour);
68
68
  const types = toStringArray(projectSettings.filament_type);
69
69
  const names = toStringArray(projectSettings.filament_settings_id);
@@ -90,6 +90,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
90
90
  const printableArea = projectSettings.printable_area;
91
91
  return {
92
92
  plates,
93
+ plateCount: Math.max(1, plateCount ?? 0, ...plates),
93
94
  objects: objects.map((o) => ({ ...o })),
94
95
  filaments,
95
96
  nozzleDiameter: asDisplayString(rawNozzle),
@@ -106,7 +107,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
106
107
  warnings: [...warnings],
107
108
  unpackedBytes,
108
109
  ...(sourcePlateOrigins
109
- ? { sourcePlateOrigins: Object.fromEntries(plates.filter((p) => Object.hasOwn(sourcePlateOrigins, p)).map((p) => [p, [sourcePlateOrigins[p][0], sourcePlateOrigins[p][1]]])) }
110
+ ? { sourcePlateOrigins: Object.fromEntries(Object.entries(sourcePlateOrigins).slice(0, 1000).map(([p, origin]) => [Number(p), [origin[0], origin[1]]])) }
110
111
  : {}),
111
112
  };
112
113
  }
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. */
@@ -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 } : {}),
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.7.2";
1
+ export declare const VERSION = "0.7.3";
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.7.3";
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "any2orca",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
+ "outputAffecting": "A project with an empty plate converts with every plate's objects on their own plate; 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",
4
5
  "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.",
5
6
  "keywords": [
6
7
  "3mf",