From d43a4f818ba235b7be63558669c5d409c54de817 Mon Sep 17 00:00:00 2001 From: bissen21 Date: Sat, 17 Dec 2022 09:45:05 -0600 Subject: [PATCH] initial commit. V0.0.1 release --- .gitignore | 2 ++ .vscode/launch.json | 26 ++++++++++++++++++++++++++ .vscode/tasks.json | 41 +++++++++++++++++++++++++++++++++++++++++ GCodeRename.csproj | 12 ++++++++++++ Program.cs | 24 ++++++++++++++++++++++++ 5 files changed, 105 insertions(+) create mode 100644 .gitignore create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json create mode 100644 GCodeRename.csproj create mode 100644 Program.cs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3dea4ce --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +bin/* +obj/* \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..907c7bb --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + "version": "0.2.0", + "configurations": [ + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/bin/Debug/net7.0/GCodeRename.dll", + "args": [], + "cwd": "${workspaceFolder}", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..ad3309e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/GCodeRename.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/GCodeRename.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", + "args": [ + "watch", + "run", + "--project", + "${workspaceFolder}/GCodeRename.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/GCodeRename.csproj b/GCodeRename.csproj new file mode 100644 index 0000000..eb54cba --- /dev/null +++ b/GCodeRename.csproj @@ -0,0 +1,12 @@ + + + + 0.0.1 + Exe + net7.0 + enable + enable + true + + + diff --git a/Program.cs b/Program.cs new file mode 100644 index 0000000..855309b --- /dev/null +++ b/Program.cs @@ -0,0 +1,24 @@ +using System; +using System.IO; +using System.Text.RegularExpressions; + +Console.WriteLine("GCode for Drawbot Conversion Tool\n* * * * * * * * * * * * * * * * *"); +string currentPath = Directory.GetCurrentDirectory(); +string[] curFiles = Directory.GetFiles(currentPath, "*.ngc?"); +foreach (string filename in curFiles) { + Console.WriteLine("Modifying: " + filename); + using (var reader = new StreamReader(filename)) { + string fileText = reader.ReadToEnd(); + fileText = Regex.Replace(fileText, "([ ][Z]([^ |\n])*)", ""); + fileText = Regex.Replace(fileText, "(\n[G][0][0]\n)", "\n"); + //Console.Write(fileText + "\n"); + string newFile = Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".gcode"; + Console.WriteLine("Saving to: " + newFile); + File.WriteAllText(newFile, fileText); + } +} + +foreach (string v in curFiles) { + Console.WriteLine("Deleting File: " + v); + File.Delete(v); +} \ No newline at end of file