Beispiel #1
0
        static void Main(string[] args)
        {
            var gcode_accumulator     = new GCodeFileAccumulator();
            var builder               = new GCodeBuilder(gcode_accumulator);
            MakerbotSettings settings = new MakerbotSettings();

            SingleMaterialFFFCompiler compiler = new SingleMaterialFFFCompiler(
                builder, settings, MakerbotAssembler.Factory);

            settings.ExtruderTempC = 200;

            compiler.Begin();

            //generate_stacked_polygon(compiler, settings);
            //generate_stacked_wavy_circle(compiler, settings);
            //generate_square(compiler, settings);
            //generate_vertical(compiler, settings);
            generate_vertical_wave(compiler, settings);

            compiler.End();

            GCodeFile gcode = gcode_accumulator.File;

            using (StreamWriter w = new StreamWriter(OUT_PATH + "generated.gcode")) {
                StandardGCodeWriter writer = new StandardGCodeWriter();
                writer.WriteFile(gcode, w);
            }
        }
Beispiel #2
0
        List <MachinePreset> populate_defaults()
        {
            List <MachinePreset> new_defaults = new List <MachinePreset>();

            register_new_mfg_machines("Makerbot", Makerbot.UUID, MakerbotSettings.EnumerateDefaults(), new_defaults);
            register_new_mfg_machines("Monoprice", Monoprice.UUID, MonopriceSettings.EnumerateDefaults(), new_defaults);
            register_new_mfg_machines("Printrbot", Printrbot.UUID, PrintrbotSettings.EnumerateDefaults(), new_defaults);
            register_new_mfg_machines("RepRap", RepRap.UUID, RepRapSettings.EnumerateDefaults(), new_defaults);
            register_new_mfg_machines("Flashforge", Flashforge.UUID, FlashforgeSettings.EnumerateDefaults(), new_defaults);
            register_new_mfg_machines("Prusa", Prusa.UUID, PrusaSettings.EnumerateDefaults(), new_defaults);

            return(new_defaults);
        }
        public MakerbotAssembler(GCodeBuilder useBuilder, SingleMaterialFFFSettings settings) : base(useBuilder, settings.Machine)
        {
            if (settings is MakerbotSettings == false)
            {
                throw new Exception("MakerbotAssembler: incorrect settings type!");
            }

            Settings = settings as MakerbotSettings;

            PositionBounds = new AxisAlignedBox2d(settings.Machine.BedSizeXMM, settings.Machine.BedSizeYMM);
            PositionBounds.Translate(-PositionBounds.Center);

            TravelGCode = 1;
        }
Beispiel #4
0
        public MakerbotAssembler(GCodeBuilder useBuilder, SingleMaterialFFFSettings settings) : base(useBuilder, settings.Machine)
        {
            if (settings is MakerbotSettings == false)
            {
                throw new Exception("MakerbotAssembler: incorrect settings type!");
            }

            Settings = settings as MakerbotSettings;

            PositionBounds = new AxisAlignedBox2d(settings.Machine.BedSizeXMM, settings.Machine.BedSizeYMM);
            PositionBounds.Translate(-PositionBounds.Center);

            // [RMS] currently bed dimensions are hardcoded in header setup, and this trips bounds-checker.
            // So, disable this checking for now.
            EnableBoundsChecking = false;

            TravelGCode = 1;
        }
Beispiel #5
0
        static GCodeInfo GenerateGCodeForFile(string filename, Action <string, string> errorF, Func <bool> cancelF)
        {
            GCodeInfo info = new GCodeInfo();

            DMesh3 mesh = StandardMeshReader.ReadMesh(filename);

            if (mesh == null || mesh.TriangleCount == 0)
            {
                throw new Exception("File " + filename + " is invalid or empty");
            }

            bool ENABLE_SUPPORT_ZSHIFT = true;

            // configure settings
            MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2);

            //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2);
            //PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus);
            settings.ExtruderTempC             = 200;
            settings.Shells                    = 2;
            settings.InteriorSolidRegionShells = 0;
            settings.SparseLinearInfillStepX   = 10;
            settings.ClipSelfOverlaps          = false;

            settings.GenerateSupport    = true;
            settings.EnableSupportShell = true;

            PrintMeshAssembly meshes = new PrintMeshAssembly();

            meshes.AddMesh(mesh);

            // slice meshes
            MeshPlanarSlicerPro slicer = new MeshPlanarSlicerPro()
            {
                LayerHeightMM = settings.LayerHeightMM,
                SliceFactoryF = PlanarSlicePro.FactoryF
            };

            slicer.Add(meshes);
            slicer.CancelF = cancelF;
            PlanarSliceStack slices = slicer.Compute();

            if (slicer.WasCancelled)
            {
                return(info);
            }
            info.SliceCount  = slices.Count;
            info.SliceBounds = slices.Bounds;

            // run print generator
            SingleMaterialFFFPrintGenPro printGen =
                new SingleMaterialFFFPrintGenPro(meshes, slices, settings);

            printGen.ErrorF  = errorF;
            printGen.CancelF = cancelF;

            if (ENABLE_SUPPORT_ZSHIFT)
            {
                printGen.LayerPostProcessor = new SupportConnectionPostProcessor()
                {
                    ZOffsetMM = 0.2f
                }
            }
            ;
            printGen.AccumulatePathSet = true;

            printGen.Generate();
            if (printGen.WasCancelled)
            {
                return(info);
            }

            GCodeFile genGCode = printGen.Result;

            info.PathBounds    = printGen.AccumulatedPaths.Bounds;
            info.ExtrudeBounds = printGen.AccumulatedPaths.ExtrudeBounds;
            info.TotalLength   = CurveUtils.ArcLength(printGen.AccumulatedPaths.AllPositionsItr());
            info.GCodeLines    = genGCode.LineCount;

            // write to in-memory string
            StandardGCodeWriter writer = new StandardGCodeWriter();

            using (MemoryStream membuf = new MemoryStream()) {
                using (StreamWriter w = new StreamWriter(membuf)) {
                    writer.WriteFile(genGCode, w);
                    info.GCodeBytes = (int)membuf.Length;
                }
            }

            info.completed = true;

            return(info);
        }
    }
Beispiel #6
0
        static void Main(string[] args)
        {
            GCodeInfo info = new GCodeInfo();

            string filename = args[0];

            DMesh3           mesh   = StandardMeshReader.ReadMesh(filename);
            AxisAlignedBox3d bounds = mesh.CachedBounds;

            MeshTransforms.Scale(mesh, MAX_DIM_MM / bounds.MaxDim);
            Vector3d basePt = mesh.CachedBounds.Point(0, 0, -1);

            MeshTransforms.Translate(mesh, -basePt);

            if (mesh.TriangleCount > MAX_TRI_COUNT)
            {
                Reducer r = new Reducer(mesh);
                r.ReduceToTriangleCount(MAX_TRI_COUNT);
                mesh = new DMesh3(mesh, true);
            }

            var start = DateTime.Now;

            bool ENABLE_SUPPORT_ZSHIFT = true;

            try {
                // configure settings
                MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2);
                //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2);
                //PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus);
                settings.ExtruderTempC             = 200;
                settings.Shells                    = 2;
                settings.InteriorSolidRegionShells = 0;
                settings.SparseLinearInfillStepX   = 10;
                settings.ClipSelfOverlaps          = false;

                settings.GenerateSupport    = true;
                settings.EnableSupportShell = true;

                PrintMeshAssembly meshes = new PrintMeshAssembly();
                meshes.AddMesh(mesh);

                // slice meshes
                MeshPlanarSlicerPro slicer = new MeshPlanarSlicerPro()
                {
                    LayerHeightMM = settings.LayerHeightMM,
                    SliceFactoryF = PlanarSlicePro.FactoryF
                };
                slicer.Add(meshes);
                PlanarSliceStack slices = slicer.Compute();
                info.SliceCount  = slices.Count;
                info.SliceBounds = slices.Bounds;

                // run print generator
                SingleMaterialFFFPrintGenPro printGen =
                    new SingleMaterialFFFPrintGenPro(meshes, slices, settings);

                if (ENABLE_SUPPORT_ZSHIFT)
                {
                    printGen.LayerPostProcessor = new SupportConnectionPostProcessor()
                    {
                        ZOffsetMM = 0.2f
                    }
                }
                ;
                printGen.AccumulatePathSet = true;

                printGen.Generate();

                GCodeFile genGCode = printGen.Result;

                info.PathBounds    = printGen.AccumulatedPaths.Bounds;
                info.ExtrudeBounds = printGen.AccumulatedPaths.ExtrudeBounds;
                info.TotalLength   = CurveUtils.ArcLength(printGen.AccumulatedPaths.AllPositionsItr());
                info.GCodeLines    = genGCode.LineCount;

                // write to in-memory string
                StandardGCodeWriter writer = new StandardGCodeWriter();
                using (MemoryStream membuf = new MemoryStream()) {
                    using (StreamWriter w = new StreamWriter(membuf)) {
                        writer.WriteFile(genGCode, w);
                        info.GCodeBytes = (int)membuf.Length;
                    }
                }

                // try to force destructor error
                printGen = null;
                genGCode = null;
                GC.Collect();
            } catch (Exception e) {
                System.Console.WriteLine("EXCEPTION:" + e.Message);
                return;
            }

            var end     = DateTime.Now;
            int seconds = (int)(end - start).TotalSeconds;

            System.Console.WriteLine("{0},{1},{2},{3},{4},{5},{6},{7},",
                                     filename, mesh.TriangleCount, "OK", seconds, info.SliceCount, info.GCodeLines, info.GCodeBytes, (int)info.TotalLength);
        }
Beispiel #7
0
        static void GenerateGCodeForSliceFile(string sliceFile)
        {
            PlanarSliceStack slices = new PlanarSliceStack();

            using (TextReader reader = new StreamReader(sliceFile)) {
                slices.ReadSimpleSliceFormat(reader);
            }

            // configure settings
            MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2);

            //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2);
            //PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus);
            settings.Shells = 2;
            settings.SparseLinearInfillStepX   = 10;
            settings.InteriorSolidRegionShells = 1;
            settings.ClipSelfOverlaps          = true;
            settings.GenerateSupport           = true;
            settings.SupportSpacingStepX       = 5.0;
            settings.SupportVolumeScale        = 1.0;

            //settings.LayerRangeFilter = new Interval1i(0,10);


            LastSettings = settings.CloneAs <SingleMaterialFFFSettings>();

            // empty...
            PrintMeshAssembly meshes = new PrintMeshAssembly();

            // run print generator
            SingleMaterialFFFPrintGenerator printGen =
                new SingleMaterialFFFPrintGenerator(meshes, slices, settings);

            printGen.LayerPostProcessor = new SupportConnectionPostProcessor()
            {
                ZOffsetMM = 0.15f
            };
            printGen.AccumulatePathSet = (SHOW_RELOADED_GCODE_PATHS == false);

            printGen.Generate();
            GCodeFile genGCode = printGen.Result;

            string sWritePath          = "../../../sample_output/generated.gcode";
            StandardGCodeWriter writer = new StandardGCodeWriter();

            using (StreamWriter w = new StreamWriter(sWritePath)) {
                writer.WriteFile(genGCode, w);
            }

            if (settings is MakerbotSettings)
            {
                System.Diagnostics.Process.Start(GPX_PATH, "-p " + sWritePath);
            }

            if (SHOW_RELOADED_GCODE_PATHS)
            {
                LoadGeneratedGCodeFile(sWritePath);
            }
            else
            {
                View.SetPaths(printGen.AccumulatedPaths, settings);
            }
        }
Beispiel #8
0
        static string GenerateGCodeForMeshes(PrintMeshAssembly meshes)
        {
            bool ENABLE_SUPPORT_ZSHIFT = true;

            // configure settings
            MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2);

            //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2);
            //PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus);
            settings.ExtruderTempC             = 200;
            settings.Shells                    = 2;
            settings.InteriorSolidRegionShells = 0;
            settings.SparseLinearInfillStepX   = 10;
            settings.ClipSelfOverlaps          = false;
            //settings.RoofLayers = settings.FloorLayers = 0;
            //settings.LayerRangeFilter = new Interval1i(245, 255);
            settings.LayerRangeFilter = new Interval1i(6, 40);

            settings.GenerateSupport    = false;
            settings.EnableSupportShell = true;
            settings.SupportSolidSpace  = 0.35;

            //settings.Machine.NozzleDiamMM = 0.75;
            //settings.Machine.MaxLayerHeightMM = 0.5;
            //settings.FillPathSpacingMM = settings.Machine.NozzleDiamMM;
            //settings.LayerHeightMM = 0.5;

            //settings.LayerRangeFilter = new Interval1i(130, 140);

            LastSettings = settings.CloneAs <SingleMaterialFFFSettings>();

            System.Console.WriteLine("Slicing...");

            // slice meshes
            MeshPlanarSlicerPro slicer = new MeshPlanarSlicerPro()
            {
                LayerHeightMM = settings.LayerHeightMM,
                SliceFactoryF = PlanarSlicePro.FactoryF
            };

            slicer.Add(meshes);
            PlanarSliceStack slices = slicer.Compute();

            System.Console.WriteLine("Generating GCode...");

            // run print generator
            SingleMaterialFFFPrintGenPro printGen =
                new SingleMaterialFFFPrintGenPro(meshes, slices, settings);

            if (ENABLE_SUPPORT_ZSHIFT)
            {
                printGen.LayerPostProcessor = new SupportConnectionPostProcessor()
                {
                    ZOffsetMM = 0.2f
                }
            }
            ;
            printGen.AccumulatePathSet = (SHOW_RELOADED_GCODE_PATHS == false);

            printGen.Generate();
            GCodeFile genGCode = printGen.Result;

            System.Console.WriteLine("Writing GCode...");

            string sWritePath          = "../../../sample_output/generated.gcode";
            StandardGCodeWriter writer = new StandardGCodeWriter();

            using (StreamWriter w = new StreamWriter(sWritePath)) {
                writer.WriteFile(genGCode, w);
            }

            if (settings is MakerbotSettings)
            {
                System.Diagnostics.Process.Start(GPX_PATH, "-p " + sWritePath);
            }

            if (SHOW_RELOADED_GCODE_PATHS == false)
            {
                View.SetPaths(printGen.AccumulatedPaths, settings);
            }

            return(sWritePath);
        }