Beispiel #1
0
        static DMesh3 GenerateTubeMeshesForGCode(string sPath, double pathWidth = 0.4)
        {
            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);
                }
            }
            GCodeToLayerTubeMeshes make_tubes = new GCodeToLayerTubeMeshes()
            {
                TubeProfile = Polygon2d.MakeCircle(pathWidth / 2, 12),
                InterpretZChangeAsLayerChange = false
            };

            make_tubes.WantTubeTypes.Add(ToolpathTypes.Travel);
            ThreeAxisCNCInterpreter interpreter = new ThreeAxisCNCInterpreter();

            interpreter.AddListener(make_tubes);
            interpreter.Interpret(gcode, new InterpretArgs());
            DMesh3 tubeMesh2 = make_tubes.GetCombinedMesh(1);

            return(tubeMesh2);
        }
Beispiel #2
0
        static void LoadGeneratedGCodeFile(string sPath)
        {
            // read gcode file
            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);
                }
            }

            // write back out gcode we loaded
            //StandardGCodeWriter writer = new StandardGCodeWriter();
            //using ( StreamWriter w = new StreamWriter("../../../sample_output/writeback.nc") ) {
            //	writer.WriteFile(gcode, w);
            //}

            GCodeToToolpaths        converter   = new GCodeToToolpaths();
            ThreeAxisCNCInterpreter interpreter = new ThreeAxisCNCInterpreter();

            interpreter.AddListener(converter);

            InterpretArgs interpArgs = new InterpretArgs();

            interpreter.Interpret(gcode, interpArgs);

            View.SetPaths(converter.PathSet);
            if (LastSettings != null)
            {
                View.PathDiameterMM = (float)LastSettings.Machine.NozzleDiamMM;
            }
        }