SliceyDicey 0.3.0

dotnet add package SliceyDicey --version 0.3.0                
NuGet\Install-Package SliceyDicey -Version 0.3.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SliceyDicey" Version="0.3.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SliceyDicey --version 0.3.0                
#r "nuget: SliceyDicey, 0.3.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SliceyDicey as a Cake Addin
#addin nuget:?package=SliceyDicey&version=0.3.0

// Install SliceyDicey as a Cake Tool
#tool nuget:?package=SliceyDicey&version=0.3.0                

SliceyDicey

A simple tool for parsing both ASCII-based and binary GCode files

Only reading for now, I have no need for writing my own files.

Reading ASCII-based GCode

// Arrange
string name = "some-random.gcode";
Stream input = new MemoryStream();

// Act
var file = await SliceyDicey.Lib.Gcode.GcodeParser.Parse(name, input, cancellationToken);

// Play around
var thumbnails = file.Thumbnails.ToList();
var filamentUsed = file.Comments
    .FirstOrDefault(x => x.Comment.StartsWith("filament used [mm] ="));
var linearMoves = file.Commands
    .Where(x => x.Command.StartsWith("G0 ") || x.Command.StartsWith("G1 "));

Reading binary GCode

// Arrange
Microsoft.Extensions.Logging.ILogger logger = null;
string name = "some-random.gcode";
Stream input = new MemoryStream();

// Act
var parser = new SliceyDicey.Lib.BinaryGcode.Parser(logger);
var file = await parser.Parse(name, input, cancellationToken);

// Play around
var thumbnails = file.Thumbnails.ToList();
var allInstructions = file.Instructions.ToList();
var comments = file.Comments.ToList();
var commands = file.Commands.ToList();

if (file.PrinterMetadata.TryGetValue("filament used [mm]", out var filamentUsed))
{
    logger.LogInformation("Using {0:.2f} mm of filament", decimal.Parse(filamentUsed));
}
else
{
    logger.LogWarning("File contains no filament usage information");
}

var linearMoves = file.Commands
    .Where(x => x.Command.StartsWith("G0 ") || x.Command.StartsWith("G1 "));
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.0 225 12/2/2023
0.2.3 168 12/2/2023
0.2.2 139 12/2/2023
0.2.1 147 12/1/2023
0.1.0 178 11/7/2023