From 3fc688751d19ffcd972c47aee7a3f08de3e0322f Mon Sep 17 00:00:00 2001 From: LutraVibes <123699770+LutraVibes@users.noreply.github.com> Date: Wed, 15 Jan 2025 17:46:42 -0500 Subject: [PATCH 1/5] Format code into standard HTML + add pleasing styles Ignore the inputs being offset :) --- Engine_Turning.HTML | 336 +++++++++++++++++++++++++------------------- 1 file changed, 194 insertions(+), 142 deletions(-) diff --git a/Engine_Turning.HTML b/Engine_Turning.HTML index c5d618c..ad10f73 100644 --- a/Engine_Turning.HTML +++ b/Engine_Turning.HTML @@ -1,156 +1,208 @@ - - Ferreri Engine Turning G-Code Generator - - -

Ferreri Engine Turning G-Code Generator

-

Experiment in generating gcode for Engine Turning, but I guess it could be used to generate gcode for any grid-like drilling.

- -
- - -
- - - -
- - -
- - -
- - -
- - -
- - -
- - -
- - -
- - -
- - - - - -
- -
- - -
-
- -
- - - - \ No newline at end of file + const blob = new Blob([gcode], { + type: 'text/plain' + }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = 'engineTurning.nc'; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + } + + + + From efa1594796cd32028edc4b1110c831f308ca2127 Mon Sep 17 00:00:00 2001 From: LutraVibes <123699770+LutraVibes@users.noreply.github.com> Date: Wed, 15 Jan 2025 17:47:26 -0500 Subject: [PATCH 2/5] Format code into standard HTML + add pleasing styles Ignore the inputs being offset :) --- surfacingGenerator.html | 819 +++++++++++++++++++++------------------- 1 file changed, 430 insertions(+), 389 deletions(-) diff --git a/surfacingGenerator.html b/surfacingGenerator.html index ed1b9d9..56ab98d 100644 --- a/surfacingGenerator.html +++ b/surfacingGenerator.html @@ -1,417 +1,458 @@ - - Surfacing G-Code Generator - - -

Surfacing G-Code Generator

-
- - - - - -
- - -
- - -
- - -
- - -
- - -
- - -
- - -
- - - - - -
- - - - - - - - - - - -
- - - - - - - -
- - -
- - -
-
- -
- - -
-
- -
- - - + return gcode; + } + + // Clear the gcode output on input change + document.querySelectorAll('input').forEach(input => { + input.addEventListener('input', clearGCode); + }); + + + + + From 88de0ebdbe442ef13cb6b160b7a0035e69b5552c Mon Sep 17 00:00:00 2001 From: LutraVibes <123699770+LutraVibes@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:30:27 -0500 Subject: [PATCH 3/5] Update Engine_Turning.HTML --- Engine_Turning.HTML | 342 +++++++++++++++++++------------------------- 1 file changed, 147 insertions(+), 195 deletions(-) diff --git a/Engine_Turning.HTML b/Engine_Turning.HTML index ad10f73..78cf9af 100644 --- a/Engine_Turning.HTML +++ b/Engine_Turning.HTML @@ -1,208 +1,160 @@ - - - Ferreri Engine Turning G-Code Generator - - - - -

Ferreri Engine Turning G-Code Generator

-

Experiment in generating gcode for Engine Turning, but I guess it could be used to generate gcode for any - grid-like drilling.

- -
- - -
- - - -
- - -
- - -
- - -
- - -
- - -
- - -
- - -
- - -
- - - - - -
- -
- - -
-
- -
- - - + function downloadNCFile() { + let gcode = document.getElementById('gcodeOutput').value; + if (!gcode) { + console.log('Gcode string is empty'); + return; + } + const blob = new Blob([gcode], { + type: 'text/plain' + }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.style.display = 'none'; + a.href = url; + a.download = 'engineTurning.nc'; + document.body.appendChild(a); + a.click(); + window.URL.revokeObjectURL(url); + } + + From d48ae735c118cc049a05a321153ccb99570e3fb6 Mon Sep 17 00:00:00 2001 From: LutraVibes <123699770+LutraVibes@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:30:35 -0500 Subject: [PATCH 4/5] Update surfacingGenerator.html --- surfacingGenerator.html | 822 +++++++++++++++++++--------------------- 1 file changed, 392 insertions(+), 430 deletions(-) diff --git a/surfacingGenerator.html b/surfacingGenerator.html index 56ab98d..8500299 100644 --- a/surfacingGenerator.html +++ b/surfacingGenerator.html @@ -1,458 +1,420 @@ + + + Surfacing G-Code Generator + + +

Surfacing G-Code Generator

+
+ + + + + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+ + +
+ + +
+
+ +
+
+ +
+ +
+
+ +
+ + - - + + + + // Function to get the toolpath for positive cutting mode + function getCuttingToolpathPositiveX(angle, stockSizeX, stockSizeY, depthOfCut, feedrate, stepoverPercentage) { + const stepover = toolDiameter * (stepoverPercentage / 100); + let gcode = ""; + + for (currentDepth = 0; currentDepth < maxDepth; currentDepth += depthOfCut) { + gcode += `G0 Z${retractHeight.toFixed(3)}\n`; // Move to safe Z height + getRapidMoveToStartingPoint(xyZeroPoint, stockSizeX, stockSizeY); + gcode += `G0 X${xZero.toFixed(3)} Y${yZero.toFixed(3)}\n`; // Rapid move to starting point + + if (currentDepth + depthOfCut <= maxDepth) + gcode += `G1 Z${(0 - currentDepth - depthOfCut).toFixed(3)} F${feedrate}\n`; // Plunge to depth + else + gcode += `G1 Z${(0 - maxDepth).toFixed(3)} F${feedrate}\n`; // Plunge to depth + + for (let y = yZero; y <= stockSizeY + yZero; y += stepover) { + gcode += `G1 X${(stockSizeX + xZero).toFixed(3)} F${feedrate}\n`; // Cut along X + gcode += `G0 Z${retractHeight.toFixed(3)}\n`; // Retract + if (y + stepover < stockSizeY + yZero) { + gcode += `G0 Y${(y + stepover).toFixed(3)} X${xZero.toFixed(3)}\n`; // Move over on Y + if (currentDepth + depthOfCut <= maxDepth) + gcode += `G1 Z${(0 - currentDepth - depthOfCut).toFixed(3)} F${feedrate}\n`; // Plunge to depth + else + gcode += `G1 Z${(0 - maxDepth).toFixed(3)} F${feedrate}\n`; // Plunge to depth + } + } + } + return gcode; + } + + // Function to get the toolpath for negative cutting mode + function getCuttingToolpathNegativeX(angle, stockSizeX, stockSizeY, depthOfCut, feedrate, stepoverPercentage) { + const stepover = toolDiameter * (stepoverPercentage / 100); + let gcode = ""; + + for (currentDepth = 0; currentDepth < maxDepth; currentDepth += depthOfCut) { + gcode += `G0 Z${retractHeight.toFixed(3)}\n`; // Move to safe Z height + getRapidMoveToStartingPoint(xyZeroPoint, stockSizeX, stockSizeY); + gcode += `G0 X${(stockSizeX + xZero).toFixed(3)} Y${(stockSizeY + yZero).toFixed(3)}\n`; // Rapid move to starting point + if (currentDepth + depthOfCut <= maxDepth) + gcode += `G1 Z${(0 - currentDepth - depthOfCut).toFixed(3)} F${feedrate}\n`; // Plunge to depth + else + gcode += `G1 Z${(0 - maxDepth).toFixed(3)} F${feedrate}\n`; // Plunge to depth + + for (let y = stockSizeY + yZero; y >= yZero; y -= stepover) { + gcode += `G1 X${xZero.toFixed(3)} F${feedrate}\n`; // Cut along X + gcode += `G0 Z${retractHeight.toFixed(3)}\n`; // Retract + if (y - stepover > yZero) { + gcode += `G0 Y${(y - stepover).toFixed(3)} X${(stockSizeX + xZero).toFixed(3)}\n`; // Move over on Y + if (currentDepth + depthOfCut <= maxDepth) + gcode += `G1 Z${(0 - currentDepth - depthOfCut).toFixed(3)} F${feedrate}\n`; // Plunge to depth + else + gcode += `G1 Z${(0 - maxDepth).toFixed(3)} F${feedrate}\n`; // Plunge to depth + } + } + } + return gcode; + } + + function getCuttingToolpathBothX(angle, stockSizeX, stockSizeY, depthOfCut, feedrate) { + const stepover = toolDiameter * (stepoverPercentage / 100); + let gcode = ""; + + for (currentDepth = 0; currentDepth < maxDepth; currentDepth += depthOfCut) { + gcode += `G0 Z${retractHeight.toFixed(3)}\n`; // Move to safe Z height + getRapidMoveToStartingPoint(xyZeroPoint, stockSizeX, stockSizeY); + gcode += `G0 X${xZero.toFixed(3)} Y${yZero.toFixed(3)}\n`; // Rapid move to starting point + if (currentDepth + depthOfCut <= maxDepth) + gcode += `G1 Z${(0 - currentDepth - depthOfCut).toFixed(3)} F${feedrate}\n`; // Plunge to depth + else + gcode += `G1 Z${(0 - maxDepth).toFixed(3)} F${feedrate}\n`; // Plunge to depth + + for (let y = yZero; y <= maximumY; y += stepover) { + gcode += `G1 X${(stockSizeX + xZero).toFixed(3)} F${feedrate}\n`; // Cut along X + if (y + stepover < maximumY) { + gcode += `G1 Y${(y + stepover).toFixed(3)}\n`; // Move over on Y + } + gcode += `G1 X${xZero.toFixed(3)}F${feedrate}\n`; // Move back on X + y += stepover; + if (y + stepover < maximumY) { + gcode += `G0 Y${(y + stepover).toFixed(3)}\n`; // Move over on Y + + } + } + } + return gcode; + } + + // Clear the gcode output on input change + document.querySelectorAll('input').forEach(input => { + input.addEventListener('input', clearGCode); + }); + + + + From 7652a5a53634696536fd4cbfe500b3fe35b87ded Mon Sep 17 00:00:00 2001 From: LutraVibes <123699770+LutraVibes@users.noreply.github.com> Date: Thu, 16 Jan 2025 15:30:44 -0500 Subject: [PATCH 5/5] Create style.css --- style.css | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 style.css diff --git a/style.css b/style.css new file mode 100644 index 0000000..fb3301e --- /dev/null +++ b/style.css @@ -0,0 +1,8 @@ +@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap'); /* Import the Roboto font from Google Fonts */ + +body { + font-family: 'Roboto', sans-serif; + margin: 20px; + background-color: #f5f5f5; /* Light grey background for better contrast */ + color: #333333; /* Dark grey text for better readability */ +}