Exemplo n.º 1
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.gcode") ) {
            //	writer.WriteFile(gcode, w);
            //}

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

            interpreter.AddListener(converter);

            InterpretArgs interpArgs = new InterpretArgs();

            interpreter.Interpret(gcode, interpArgs);

            View.SetPaths(converter.PathSet);
            if (LastSettings != null)
            {
                View.PathDiameterMM = (float)LastSettings.Machine.NozzleDiamMM;
            }
        }
Exemplo n.º 2
0
        static DMesh3 GenerateTubeMeshesForGCode(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);
                }
            }
            GCodeToLayerTubeMeshes make_tubes = new GCodeToLayerTubeMeshes()
            {
                TubeProfile = Polygon2d.MakeCircle(0.2f, 12)
            };
            MakerbotInterpreter interpreter = new MakerbotInterpreter();

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

            return(tubeMesh2);
        }
Exemplo n.º 3
0
        public void Begin(GCodeFile gcode)
        {
            GCode = gcode;

            listener = new GCodeAnimationLister();
            listener.OnBeginDepositF = OnBeginDepositF;
            listener.OnBeginTravelF  = OnBeginTravelF;
            listener.OnMoveToAtTimeF = OnMoveToAtTimeF;
            listener.SpeedScale      = SpeedUnitsToMMPerSec;

            interp = new MakerbotInterpreter();
            interp.AddListener(listener);
            active_anim = interp.InterpretInteractive(GCode, InterpretArgs.Default).GetEnumerator();
            isFinished  = false;

            LaserGO       = GameObjectFactory.CreateLineGO("laser", Colorf.VideoRed, 0.5f, LineWidthType.World);
            HeatParticles = new PrintTempParticleSystem(CC.ActiveScene.RootGameObject);

            StartTime       = FPlatform.RealTime();
            CurrentPosition = Vector3d.Zero;
            PrevPosition    = Vector3d.Zero;
            PrevTime        = 0;
        }
Exemplo n.º 4
0
        static 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);
                }
            }

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

            interpreter.AddListener(converter);
            InterpretArgs interpArgs = new InterpretArgs();

            interpreter.Interpret(gcode, interpArgs);

            ToolpathSet Paths = converter.PathSet;

            View.SetPaths(Paths);
        }
Exemplo n.º 5
0
            public void Compute()
            {
                RequestCancel = false;

                printer =
                    new SingleMaterialFFFPrintGenerator(Meshes, SliceSet, PrintSettings);

                if (PrintSettings.EnableSupportReleaseOpt)
                {
                    printer.LayerPostProcessor = new SupportConnectionPostProcessor()
                    {
                        ZOffsetMM = PrintSettings.SupportReleaseGap
                    };
                }

                // if we aren't interpreting GCode, we want generator to return its path set
                printer.AccumulatePathSet = (InterpretGCodePaths == false);

                // set clip region
                Box2d clip_box = new Box2d(Vector2d.Zero,
                                           new Vector2d(CC.Settings.BedSizeXMM / 2, CC.Settings.BedSizeYMM / 2));

                printer.PathClipRegions = new List <GeneralPolygon2d>()
                {
                    new GeneralPolygon2d(new Polygon2d(clip_box.ComputeVertices()))
                };

                printer.ErrorF = (msg, trace) => {
                    if (RequestCancel == false)
                    {
                        DebugUtil.Log(2, "Slicer Error! msg: {0} stack {1}", msg, trace);
                    }
                };

                DebugUtil.Log(2, "Generating gcode...");

                try {
                    if (printer.Generate() == false)
                    {
                        throw new Exception("generate failed");   // this will be caught below
                    }
                    gcode = printer.Result;

                    //DebugUtil.Log(2, "Interpreting gcode...");

                    if (InterpretGCodePaths)
                    {
                        GCodeToToolpaths    converter   = new GCodeToToolpaths();
                        MakerbotInterpreter interpreter = new MakerbotInterpreter();
                        interpreter.AddListener(converter);
                        InterpretArgs interpArgs = new InterpretArgs();
                        interpreter.Interpret(gcode, interpArgs);
                        paths = converter.PathSet;
                    }
                    else
                    {
                        paths = printer.AccumulatedPaths;
                    }

                    //DebugUtil.Log(2, "Detecting layers...");

                    layerInfo = new LayersDetector(paths);

                    Success = true;
                } catch (Exception e) {
                    DebugUtil.Log("ToolpathGenerator.Compute: exception: " + e.Message);
                    Success = false;
                }

                Finished = true;
            }