Skip to content

Commit

Permalink
Use defaultName if the shape doesn't have a name
Browse files Browse the repository at this point in the history
  • Loading branch information
North101 authored and sgenoud committed Jan 17, 2025
1 parent 3ad7b58 commit a1444e9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/studio/src/utils/saveShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ const mapExt = (ext) => {
};

export default async function saveShapes(shapeId, fileType = "stl", code) {
const defaultName = await builderAPI.extractDefaultNameFromCode(code);
const shapes = await builderAPI.exportShape(fileType, shapeId);
if (shapes.length === 1) {
const { blob, name } = shapes[0];
const ext = mapExt(fileType);

await fileSave(blob, {
fileName: `${name || "shape"}.${ext}`,
fileName: `${name ?? defaultName ?? "shape"}.${ext}`,
extensions: [`.${ext}`],
description: `Save ${name || "shape"} as ${fileType}`,
description: `Save ${name ?? defaultName ?? "shape"} as ${fileType}`,
});
return;
}

const defaultName = await builderAPI.extractDefaultNameFromCode(code);
const zip = new JSZip();
shapes.forEach((shape, i) => {
zip.file(`${shape.name || `shape-${i}`}.${mapExt(fileType)}`, shape.blob);
Expand Down

0 comments on commit a1444e9

Please sign in to comment.