-
Notifications
You must be signed in to change notification settings - Fork 539
Open
Description
Could you help me to use this library to export my three.js scene to dxf?
function exportSceneToSTL(scene) {
const exporter = new STLExporter();
return exporter.parse(scene, { binary: false }); // ASCII STL
}
async function convertSTLtoDXF(stlString) {
let deserializedStl = stlDeserializer.deserialize(
{
output: "csg", //jscad
},
stlString
);
console.log("CSG data were got");
console.log(dxfSerializer);
let dxfStringArray = dxfSerializer.serialize(deserializedStl);
console.log("DXF data were got");
return dxfStringArray;
}
function downloadDXF(dxfString, filename = "scene.dxf") {
const blob = new Blob([dxfString], { type: "application/dxf" });
const link = document.createElement("a");
link.href = URL.createObjectURL(blob);
link.download = filename;
link.click();
}
/**
* Action Listeners
*/
// Export on spacebar press
window.addEventListener("keydown", async (event) => {
if (event.code === "Space") {
const stlString = exportSceneToSTL(scene);
const dxfString = await convertSTLtoDXF(stlString);
downloadDXF(dxfString);
}
});
I tried this steps, but it returns Uncaught (in promise) Error: only JSCAD geometries can be serialized to DXF
error...
(The code is inspired from this discussion)
Metadata
Metadata
Assignees
Labels
No labels