mirror of
https://github.com/TECHNOFAB11/ergogen.git
synced 2025-12-16 01:43:49 +01:00
18 lines
484 B
JavaScript
18 lines
484 B
JavaScript
|
|
const m = require('makerjs')
|
||
|
|
const fs = require('fs-extra')
|
||
|
|
const path = require('path')
|
||
|
|
|
||
|
|
const u = require('./utils')
|
||
|
|
|
||
|
|
exports.dump_model = (model, file='model', debug=false) => {
|
||
|
|
const assembly = m.model.originate({
|
||
|
|
models: u.deepcopy(model),
|
||
|
|
units: 'mm'
|
||
|
|
})
|
||
|
|
|
||
|
|
fs.mkdirpSync(path.dirname(`${file}.dxf`))
|
||
|
|
fs.writeFileSync(`${file}.dxf`, m.exporter.toDXF(assembly))
|
||
|
|
if (debug) {
|
||
|
|
fs.writeJSONSync(`${file}.json`, assembly, {spaces: 4})
|
||
|
|
}
|
||
|
|
}
|