-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
bs893
committed
Feb 15, 2021
1 parent
a8d5142
commit a41f339
Showing
5 changed files
with
49 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var fs = require('fs'); | ||
var Docker = require('dockerode'); | ||
var docker = new Docker(); //defaults to above if env variables are not used | ||
|
||
var nodeCuraEngine = {}; | ||
|
||
nodeCuraEngine.render = function (options, callback) { | ||
|
||
if (options.verbose) | ||
console.log(options) | ||
|
||
docker.pull('dimfacion/curaengine:latest', function (err, stream) { | ||
docker.run('dimfacion/curaengine:latest', ['slice', '-j', '/usr/definitions/creality_ender3.def.json', '-l', options.inputFile, '-o', options.outputFile], process.stdout, {"Binds": [ "/tmp:/tmp:rw" ]}, function (err, data, container) { | ||
if (err){ | ||
return callback({ message: err }) | ||
} | ||
|
||
callback() | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = nodeCuraEngine; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,23 @@ | ||
var fs = require('fs'), | ||
childProcess = require('child_process'), | ||
var fs = require('fs'); | ||
var Docker = require('dockerode'); | ||
var docker = new Docker(); //defaults to above if env variables are not used | ||
|
||
nodePrusaSlicer = {} | ||
|
||
function getShellCommand (o) { | ||
|
||
var shellCommand | ||
|
||
shellCommand = [ | ||
'slic3r-prusa3d', | ||
'--output ' + o.outputFile, | ||
|
||
// Output options | ||
o.outputFilenameFormat ? | ||
'--output-filename-format ' + o.outputFilenameFormat : '', | ||
|
||
// Transform options | ||
o.scale ? '--scale ' + o.scale : '', | ||
o.rotate ? '--rotate ' + o.rotate : '', | ||
o.duplicate ? '--duplicate ' + o.duplicate : '', | ||
o.duplicateGrid ? '--duplicate-grid ' + o.duplicateGrid : '', | ||
o.duplicateDistance ? '--duplicate-distance ' + o.duplicateDistance : '', | ||
|
||
//Input options | ||
o.inputFile ? o.inputFile : '', | ||
|
||
//Load config file | ||
o.configFile ? '--load ' + o.configFile : '' | ||
] | ||
|
||
return shellCommand.join(' ') | ||
} | ||
nodePrusaSlicer = {} | ||
|
||
nodePrusaSlicer.render = function (options, callback) { | ||
|
||
var shellCommand | ||
|
||
shellCommand = getShellCommand(options) | ||
|
||
if (options.verbose) | ||
console.log(shellCommand) | ||
|
||
childProcess.exec( | ||
shellCommand, | ||
function (error, stdout, stderr) { | ||
console.log(options) | ||
|
||
if (stderr){ | ||
return callback({ message: stderr }) | ||
docker.pull('dimfacion/prusaslicer', function (err, stream) { | ||
docker.run('dimfacion/prusaslicer', ['-g', options.inputFile], process.stdout, {"Binds": [ "/tmp:/tmp:rw" ]}, function (err, data, container) { | ||
if (err){ | ||
return callback({ message: err }) | ||
} | ||
|
||
if (error) | ||
return callback(error) | ||
|
||
callback() | ||
} | ||
) | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = nodePrusaSlicer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,23 @@ | ||
var fs = require('fs'), | ||
childProcess = require('child_process'), | ||
|
||
nodeSlicer = {} | ||
var fs = require('fs'); | ||
var Docker = require('dockerode'); | ||
var docker = new Docker(); //defaults to above if env variables are not used | ||
|
||
function getShellCommand (o) { | ||
|
||
var shellCommand | ||
|
||
shellCommand = [ | ||
'slic3r', | ||
'--output ' + o.outputFile, | ||
|
||
// Output options | ||
o.outputFilenameFormat ? | ||
'--output-filename-format ' + o.outputFilenameFormat : '', | ||
|
||
// Transform options | ||
o.scale ? '--scale ' + o.scale : '', | ||
o.rotate ? '--rotate ' + o.rotate : '', | ||
o.duplicate ? '--duplicate ' + o.duplicate : '', | ||
o.duplicateGrid ? '--duplicate-grid ' + o.duplicateGrid : '', | ||
o.duplicateDistance ? '--duplicate-distance ' + o.duplicateDistance : '', | ||
|
||
//Input options | ||
o.inputFile ? o.inputFile : '', | ||
|
||
//Load config file | ||
o.configFile ? '--load ' + o.configFile : '' | ||
] | ||
|
||
return shellCommand.join(' ') | ||
} | ||
var nodeSlicer = {}; | ||
|
||
nodeSlicer.render = function (options, callback) { | ||
|
||
var shellCommand | ||
|
||
shellCommand = getShellCommand(options) | ||
|
||
if (options.verbose) | ||
console.log(shellCommand) | ||
console.log(options) | ||
|
||
childProcess.exec( | ||
shellCommand, | ||
function (error, stdout, stderr) { | ||
|
||
if (stderr){ | ||
return callback({ message: stderr }) | ||
docker.pull('dimfacion/slic3r', function (err, stream) { | ||
docker.run('dimfacion/slic3r', ['--no-gui', options.inputFile], process.stdout, {"Binds": [ "/tmp:/tmp:rw" ]}, function (err, data, container) { | ||
if (err){ | ||
return callback({ message: err }) | ||
} | ||
|
||
if (error) | ||
return callback(error) | ||
|
||
callback() | ||
} | ||
) | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = nodeSlicer; |