我正在尝试在我的 C# 项目中获取或计算 gcode(3D 打印)文件的体积。要阅读我正在使用这个第三方库的 gcode: https ://github.com/gradientspace/gsGCode
可惜作者还没回复。
现在,这就是我读取文件的方式:
public gs.GCodeFile Load(string path)
{
try
{
GenericGCodeParser parse = new GenericGCodeParser();
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs);
return parse.Parse(sr);
}
catch(Exception)
{
return null;
}
}
这让我得到了所有 gcode 行的列表。
现在我需要根据这些信息计算出音量。这是我用于阅读的 gcode 文件:https ://andreas-reitberger.de/wp-content/uploads/2015/12/4x_rod_0.1mm_PET_MK3.zip
PS 我知道该卷是写在 gcode 文件的注释中的,但这不是必须的,也不可靠。谢谢,