Is there any way to export scene into DXF file?

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 there
I am trying to use this code but it seems that I am too newbie to javascript.
How do you load the JScadIO module?

Hi again
I´ve tried this:
var objDeSerializer = require(’@jscad/obj-deserializer’);
var stlDeSerializer = require(’@jscad/stl-deserializer’);
var dxfSerializer = require(’@jscad/dxf-serializer’);

const fs = require(‘fs’);
fs.readFile(‘sceneOBJ.obj’, ‘utf-8’ , (err, data) => {
var deserializedObj = objDeSerializer.deserialize(data, data, {output: ‘geometry’});
var dxfStringArray = dxfSerializer.serialize(deserializedObj);
console.log(dxfStringArray);
});

It gives me this error:
Error: only JSCAD geometries can be serialized to DXF

Any clues?

Typescript

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));

Thanks for the answer.

Haven´t try it yet. I´ll tell you anything I get.

Done! Thanks for the help.