Code Monkey home page Code Monkey logo

gcodenet's Introduction

GCodeNet

Import, export, and manipulate GCode for 3d printing.

Changes

Updated to netstandard 2.0 /2.1
Fixed number parsing for non english language os.

GCode format

Create a GCode command

//Create a G1 command (Rapid Linear Movement)
var cmd = new Command(CommandType.G, 1);
cmd.SetParameterValue(ParameterType.X, 10);
cmd.SetParameterValue(ParameterType.Y, 20);

//Convert to GCode
Console.WriteLine(cmd.ToGCode()); //Output: "G1 X10 Y20"

//Convert to GCode with the CRC
Console.WriteLine(cmd.ToGCode(addCrc: true)); //Output: "G1 X10 Y20*116"

//Convert to GCode with the CRC and a line number
Console.WriteLine(cmd.ToGCode(addCrc: true, lineNumber: 4)); //Output: "N4 G1 X10 Y20*46"

Create a command from GCode

var cmd = Command.Parse("G1 X10 Y20");

Console.WriteLine(cmd.CommandType); //Output: "G"
Console.WriteLine(cmd.CommandSubType); //Output: "1"
Console.WriteLine(cmd.GetParameterValue(ParameterType.X)); //Output: "10"
Console.WriteLine(cmd.GetParameterValue(ParameterType.Y)); //Output: "20"

Create GCode using a mapped command object

var cmd = new RapidLinearMove();
cmd.MoveX = 10;
cmd.MoveY = 20;

Console.WriteLine(cmd.CommandType); //Output: "G"
Console.WriteLine(cmd.CommandSubType); //Output: "1"
Console.WriteLine(cmd.GetParameterValue(ParameterType.X)); //Output: "10"
Console.WriteLine(cmd.GetParameterValue(ParameterType.Y)); //Output: "20"

Console.WriteLine(cmd.ToGCode()); //Output: "G1 X10 Y20 S0"

Create a mapped command object from GCode

var cmd = CommandMapping.Parse("G1 X10 Y20") as RapidLinearMove;

Console.WriteLine(cmd.CommandType); //Output: "G"
Console.WriteLine(cmd.CommandSubType); //Output: "1"
Console.WriteLine(cmd.MoveX); //Output: "10"
Console.WriteLine(cmd.MoveY); //Output: "20"
Console.WriteLine(cmd.ToGCode()); //Output: "G1 X10 Y20 S0"

gcodenet's People

Contributors

chrismiller7 avatar peterlanoie avatar bennybread avatar hansmbakker avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.