Skip to content

Commit

Permalink
Expose binary STL export in the workbench
Browse files Browse the repository at this point in the history
  • Loading branch information
sgenoud committed Jan 3, 2024
1 parent c21f181 commit e112436
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/studio/src/builder.worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ const buildBlob = (
}
) => {
if (fileType === "stl") return shape.blobSTL(meshConfig);
if (fileType === "stl-binary")
return shape.blobSTL({ ...meshConfig, binary: true });
if (fileType === "step") return shape.blobSTEP();
throw new Error(`Filetype "${fileType}" unknown for export.`);
};
Expand Down
5 changes: 3 additions & 2 deletions packages/studio/src/utils/saveShape.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ export default async function saveShapes(shapeId, fileType = "stl") {
const shapes = await builderAPI.exportShape(fileType, shapeId);
if (shapes.length === 1) {
const { blob, name } = shapes[0];
const ext = fileType === "stl-binary" ? "stl" : fileType;
await fileSave(blob, {
fileName: `${name || "shape"}.${fileType}`,
extensions: [`.${fileType}`],
fileName: `${name || "shape"}.${ext}`,
extensions: [`.${ext}`],
description: `Save ${name || "shape"} as ${fileType}`,
});
return;
Expand Down
8 changes: 8 additions & 0 deletions packages/studio/src/visualiser/editor/DownloadDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ export default function DownloadDialog({ onClose }) {
/>
<span>STL</span>
</label>
<label>
<input
checked={saveMode === "stl-binary"}
type="radio"
onClick={() => setSaveMode("stl-binary")}
/>
<span>STL (binary)</span>
</label>
</>
)}
<label>
Expand Down

0 comments on commit e112436

Please sign in to comment.