我正在尝试创建一个打开GCode文件并显示或生成图像的应用程序。基本上是一个小的Gcode查看器。
我坚持从GCode文件获取路径:
void LoadGCodeFile(string sPath)
{
GenericGCodeParser parser = new GenericGCodeParser();
GCodeFile gcode;
using (FileStream fs = new FileStream(sPath, FileMode.Open, FileAccess.Read))
{
using (TextReader reader = new StreamReader(fs))
{
gcode = parser.Parse(reader);
}
}
gcode.ToString().Replace(".", ",");
//testing
foreach (var gc in gcode.AllLines())
{
if (gc.type == GCodeLine.LType.GCode)
{
foreach (var param in gc.parameters)
{
richTextBox.Text += "Line: " + gc.lineNumber + " Code: " + gc.code + " Identifier: " + param.identifier + " Value: " + param.doubleValue + " Type: " + param.type + Environment.NewLine;
}
}
else
richTextBox.Text += "Line: " + gc.lineNumber + " Code: " + gc.code + " Parameters: " + gc.parameters + " Type: " + gc.type + Environment.NewLine;
}
GCodeToToolpaths converter = new GCodeToToolpaths();
MakerbotInterpreter interpreter = new MakerbotInterpreter();
interpreter.AddListener(converter);
InterpretArgs interpArgs = new InterpretArgs();
interpreter.Interpret(gcode, interpArgs);
ToolpathSet Paths = converter.PathSet;
}
我的Gcode文件(相对位置):link
(我用于此gsGCode / gsSlicer / Clipper库)