maintain gcode header/footer padding with substitutions
This commit is contained in:
parent
0ddfdeb376
commit
00ca621f4a
3 changed files with 18 additions and 11 deletions
|
|
@ -980,7 +980,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
function constReplace(str, consts, start) {
|
||||
function constReplace(str, consts, start, pad) {
|
||||
let cs = str.indexOf("{", start || 0),
|
||||
ce = str.indexOf("}", cs),
|
||||
tok, nutok, nustr;
|
||||
|
|
@ -992,6 +992,9 @@
|
|||
constOp(tok, consts, "/", function(v1,v2) { return v1/v2 }) ||
|
||||
constOp(tok, consts, "*", function(v1,v2) { return v1*v2 }) ||
|
||||
consts[tok] || 0;
|
||||
if (pad) {
|
||||
nutok = nutok.toString().padEnd(ce-cs+1, ' ');
|
||||
}
|
||||
nustr = str.replace("{"+tok+"}",nutok);
|
||||
return constReplace(nustr, consts, ce+1+(nustr.length-str.length));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -116,8 +116,12 @@
|
|||
}
|
||||
};
|
||||
|
||||
function appendSub(line) {
|
||||
append(print.constReplace(line, subst));
|
||||
function appendSubPad(line, pad) {
|
||||
appendSub(line, true);
|
||||
}
|
||||
|
||||
function appendSub(line, pad) {
|
||||
append(print.constReplace(line, subst, 0, pad));
|
||||
}
|
||||
|
||||
function appendAll(arr) {
|
||||
|
|
@ -126,10 +130,10 @@
|
|||
arr.forEach(function(line) { append(line) });
|
||||
}
|
||||
|
||||
function appendAllSub(arr) {
|
||||
function appendAllSub(arr, pad) {
|
||||
if (!arr) return;
|
||||
if (!Array.isArray(arr)) arr = [ arr ];
|
||||
arr.forEach(function(line) { appendSub(line) });
|
||||
arr.forEach(function(line) { appendSub(line, pad) });
|
||||
}
|
||||
|
||||
append(`; Generated by Kiri:Moto ${KIRI.version}`);
|
||||
|
|
@ -174,11 +178,11 @@
|
|||
if (line.indexOf("{tool}") > 0 && extruders.length > 1) {
|
||||
for (let i=0; i<extruders.length; i++) {
|
||||
subst.tool = i;
|
||||
appendSub(line);
|
||||
appendSubPad(line);
|
||||
}
|
||||
subst.tool = 0;
|
||||
} else {
|
||||
appendSub(line);
|
||||
appendSubPad(line);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -275,8 +279,8 @@
|
|||
path.layer === 0 ?
|
||||
(process.firstSliceHeight || process.sliceHeight) : path.height);
|
||||
|
||||
subst.z = zpos = path.z;
|
||||
subst.Z = subst.z;
|
||||
zpos = path.z;
|
||||
subst.z = subst.Z = zpos.round(3);
|
||||
subst.e = subst.E = outputLength;
|
||||
subst.layer = layer;
|
||||
subst.height = path.height.toFixed(3);
|
||||
|
|
|
|||
|
|
@ -873,8 +873,8 @@ th, tr, td, label {
|
|||
min-height: 4em !important;
|
||||
}
|
||||
#code-preview-textarea {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
width: 40em;
|
||||
height: 12em;
|
||||
font-size: 10px;
|
||||
}
|
||||
.mod-end {
|
||||
|
|
|
|||
Loading…
Reference in a new issue