在C#中计算gcode文件的容量

问题描述 投票:1回答:1

我正在尝试获取或计算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行的列表。

enter image description here

<code>code</code>

现在,我需要根据此信息计算体积。这是我用于读取的gcode文件:https://andreas-reitberger.de/wp-content/uploads/2015/12/4x_rod_0.1mm_PET_MK3.zip

P.S。我知道该卷写在gcode文件的注释中,但这不是必须的,也不可靠。谢谢,

c# volume g-code
1个回答
0
投票

您出于任何原因使用gcode吗?如果您要的是物体的体积而不是塑料的体积,那么您就迷失了方向,那就是要从gcode进行模型推断,这很可能会导致错误,因此您应该从gcode进行此操作。大概gcode是从stl文件生成的?如果是这种情况,那么您最好根据stl文件计算体积。参见How do I calculate the volume of an object stored in STL files?

© www.soinside.com 2019 - 2024. All rights reserved.