Hi. I know that similar question alredy asked in this forum but I didn`t find working answer there.
I know that Three.JS have several exporters. Maybe someone found solution to convert scene to DXF format using for example STL or OBJ or any other existed exporter?
Please share your solution if you have it. Thanks.
The repository does not provide a DXF exporter. I’m also not aware of a third-party project. You probably have to export to something else and then convert to DXF.
Maybe it will help someone. There is package npm JScadIO that can convert STL to DXF. But there is a problem with axist
const stlData = exporter.parse(object3d);
console.log('STL data were got');
let deserializedStl = JScadIO.stlDeSerializer.deserialize(stlData, null, {
output: 'csg'
});
console.log('CSG data were got');
let dxfStringArray = JScadIO.dxfSerializer.serialize(deserializedStl);
console.log('DXF data were got');
Hi again
I´ve tried this:
var objDeSerializer = require(’@jscad/obj-deserializer’);
var stlDeSerializer = require(’@jscad/stl-deserializer’);
var dxfSerializer = require(’@jscad/dxf-serializer’);
This is code from the backend, you should get stlData on the frontend using STLExporter:
import * as JScadIO from ‘@jscad/io’;
let deserializedStl = JScadIO.stlDeSerializer.deserialize(stlData, null, {
output: ‘csg’ //jscad
});
console.log(‘CSG data were got’);
let dxfStringArray = JScadIO.dxfSerializer.serialize(deserializedStl);
console.log(‘DXF data were got’);
Code from the frontend:
import { STLExporter } from ‘three/examples/jsm/exporters/STLExporter’;
let exporter = new STLExporter();
let objects3d: THREE.Object3D[] = [];
const stlData = exporter.parse(objects3d[i]);
let blob = new Blob([stlData], { type: ‘text/plain’ });
filesToReturn.push(new File([blob], objects3d[i].name));