a DSL to do numerical control for CNC machines
gwen 3690b6ed6f spooling | 3 gadi atpakaļ | |
---|---|---|
examples | 4 gadi atpakaļ | |
.gitignore | 4 gadi atpakaļ | |
LICENSE | 4 gadi atpakaļ | |
README.md | 3 gadi atpakaļ | |
cylinder.jsnc | 4 gadi atpakaļ | |
gcode.json | 4 gadi atpakaļ | |
index.html | 4 gadi atpakaļ | |
index.js | 4 gadi atpakaļ | |
jsconfig.json | 4 gadi atpakaļ | |
stdPaths.jsnc | 4 gadi atpakaļ |
JSNC is a small DSL and library for generating gcode for CNC machines. It allows you to use all the power of a scripting language to create otherwise difficult toolpaths. It is inspired in part by OpenSCAD.
For the moment the "installation" is just cloning the repo and running an http server in the folder.
Here is a snippet that generates a Lorentz Attractor. goodluck modeling THAT in autocad :P
let x = 0.01;
let y = 0.01;
let z = 0.01;
let o = 10;
let p = 28;
let B = 8 / 3;
let dt = 0.001;
let scale = 2;
G21
G90
G0 Z0 F1300
for (let i = 0; i < 100000; i++) {
const dx = o * (y - x);
const dy = x * (p - z) - y;
const dz = x * y - B * z;
x += dx * dt;
y += dy * dt;
z += dz * dt;
G0 X${trnc(x)*scale} Y${trnc(y)*scale}
}
function trnc(v){
return Math.round(v*1000)/1000
}
G0 Z1
M5