diff --git a/js/createform.js b/js/createform.js index 9a47a2e..1aea81b 100644 --- a/js/createform.js +++ b/js/createform.js @@ -157,11 +157,12 @@ var startGcode = /*html*/ `
Inputting the correct number will attempt to move the print into the centre of the bed. If the 0,0 at centre button is checked for a delta, also enter your bed diameter. Please check the gcode to ensure it will fit on your bed.
+Inputting the correct number will attempt to move the print into the centre of the bed. If the 0,0 at centre button is checked for a delta, also enter your bed diameter. Please check the gcode to ensure it will fit on your bed. For unusual 3D printers, apply X/Y offsets to shift the gcode on the build platform. 99.9% of users will leave this on 0,0. Please ensure you check a gcode preview before printing if you use this feature.
You may add extra margin for clearing bed clips, etc. Caution! If this is too large on small printers the squares will overlap. You may also use a negative value to space the squares further apart. Make sure to preview the gcode before printing!
`; diff --git a/js/gcodeprocessing.js b/js/gcodeprocessing.js index 58ee5cd..1e5f6d1 100644 --- a/js/gcodeprocessing.js +++ b/js/gcodeprocessing.js @@ -130,6 +130,8 @@ function processGcode(formName) { var bedX = Math.round((formName.bedx.value-120)/2); var bedY = Math.round((formName.bedy.value-120)/2); } + var offsetX = formName.offsetx.value; + var offsetY = formName.offsety.value; var abl = formName.abl.value; var customStart = formName.startgcode.value; var customEnd = formName.endgcode.value; @@ -331,6 +333,7 @@ function processGcode(formName) { firstlayerArray.forEach(function(index, item){ if(firstlayerArray[item].search(/X/) > -1){ var value = parseFloat(firstlayerArray[item].match(regexp)[0].substring(1)) + offsets[i*2]; + value += parseFloat(offsetX); firstlayerArray[item] = firstlayerArray[item].replace(regexp, "X"+String(value.toFixed(4))); } }); @@ -338,7 +341,8 @@ function processGcode(formName) { firstlayerArray.forEach(function(index, item){ if(firstlayerArray[item].search(/Y/) > -1){ var value = parseFloat(firstlayerArray[item].match(regexp)[0].substring(1)) + offsets[i*2+1]; - firstlayerArray[item] = firstlayerArray[item].replace(regexp, "Y"+String(value.toFixed(4))) + value += parseFloat(offsetY); + firstlayerArray[item] = firstlayerArray[item].replace(regexp, "Y"+String(value.toFixed(4))); } }); square = firstlayerArray.join("\n"); @@ -411,6 +415,7 @@ function processGcode(formName) { gcodeArray.forEach(function(index, item){ if(gcodeArray[item].search(/X/) > -1){ var value = parseFloat(gcodeArray[item].match(regexp)[0].substring(1)) - 50; + value += parseFloat(offsetX); gcodeArray[item] = gcodeArray[item].replace(regexp, "X"+String(value.toFixed(4))); } }); @@ -418,6 +423,7 @@ function processGcode(formName) { gcodeArray.forEach(function(index, item){ if(gcodeArray[item].search(/Y/) > -1){ var value = parseFloat(gcodeArray[item].match(regexp)[0].substring(1)) - 50; + value += parseFloat(offsetY); gcodeArray[item] = gcodeArray[item].replace(regexp, "Y"+String(value.toFixed(4))) } }); @@ -429,6 +435,7 @@ function processGcode(formName) { gcodeArray.forEach(function(index, item){ if(gcodeArray[item].search(/X/) > -1){ var value = parseFloat(gcodeArray[item].match(regexp)[0].substring(1)) + bedX; + value += parseFloat(offsetX); gcodeArray[item] = gcodeArray[item].replace(regexp, "X"+String(value.toFixed(4))); } }); @@ -440,6 +447,7 @@ function processGcode(formName) { gcodeArray.forEach(function(index, item){ if(gcodeArray[item].search(/Y/) > -1){ var value = parseFloat(gcodeArray[item].match(regexp)[0].substring(1)) + bedY; + value += parseFloat(offsetY); gcodeArray[item] = gcodeArray[item].replace(regexp, "Y"+String(value.toFixed(4))) } });