A simple C# project to parse gcode files and get the estimated print time and extruded filament volume. The logic behind the project is based on the gCodeViewer by @hudbrog.
Project: https://github.com/hudbrog/gCodeViewer
License: https://github.com/hudbrog/gCodeViewer/blob/master/LICENSE (https://creativecommons.org/licenses/by/4.0/)
Get the latest version from nuget.org
You can use the GcodeParser.Instance
to parse any gcode file.
public async Task ParseGcodeAsync()
{
public string testfile = @"Gcodes\Test.gcode";
var prog = new Progress<int>(percent =>
{
Console.WriteLine($"Parsed: {percent}%");
});
if (File.Exists(testfile))
{
CancellationTokenSource cts = new CancellationTokenSource();
var gcode = await GcodeParser.Instance.FromFileAsync(testfile, prog, cts.Token, false);
if (gcode != null)
{
Console.WriteLine($"Gcode parsed in: {gcode.ParsingDuration}");
}
else
Assert.Fail($"Parsed gcoe was null: {testfile}");
}
else
Assert.Fail($"{testfile} not found!");
}
RCoreSharp: https://github.com/AndreasReitberger/CoreSharp
OctoPrintRestApiSharp: https://github.com/AndreasReitberger/OctoPrintRestApiSharp