示例#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);
            }
        }
示例#2
0
        public static void DoGCodeExport(string sFilename)
        {
            if (sFilename != null && sFilename.Length > 0)
            {
                if (string.IsNullOrEmpty(Path.GetExtension(sFilename)))
                {
                    sFilename = sFilename + ".gcode";
                }

                StandardGCodeWriter writer = new StandardGCodeWriter();
                using (StreamWriter w = new StreamWriter(sFilename)) {
                    writer.WriteFile(CC.Toolpather.CurrentGCode, w);
                }

                CotangentAnalytics.ExportGCode();

                if (CC.PrinterDB.ActivePreset.Settings is gs.info.ISailfishSettings)
                {
                    gs.info.ISailfishSettings sailfish = CC.PrinterDB.ActivePreset.Settings as gs.info.ISailfishSettings;
                    Task.Run(() => {
                        string GPX_PATH = Path.Combine(FPlatform.GameExecutablePath(), "utilities/gpx.exe");
                        string args     = sailfish.GPXModelFlag + " -p " + sFilename;
                        DebugUtil.Log("Running " + GPX_PATH + " " + args);
                        System.Diagnostics.Process.Start(GPX_PATH, args);
                    });
                }
            }
        }
示例#3
0
        protected void SaveGCode(string path, GCodeFile file)
        {
            logger.WriteLine($"Saving file to {path}");
            using var streamWriter = new StreamWriter(path);
            var gCodeWriter = new StandardGCodeWriter();

            gCodeWriter.WriteFile(file, streamWriter);
        }
示例#4
0
        static void Main(string[] args)
        {
            CappedCylinderGenerator cylgen = new CappedCylinderGenerator()
            {
                BaseRadius = 10, TopRadius = 5, Height = 20, Slices = 32
            };
            DMesh3 mesh = cylgen.Generate().MakeDMesh();

            MeshTransforms.ConvertYUpToZUp(mesh);       // g3 meshes are usually Y-up

            // center mesh above origin
            AxisAlignedBox3d bounds       = mesh.CachedBounds;
            Vector3d         baseCenterPt = bounds.Center - bounds.Extents.z * Vector3d.AxisZ;

            MeshTransforms.Translate(mesh, -baseCenterPt);

            // create print mesh set
            PrintMeshAssembly meshes = new PrintMeshAssembly();

            meshes.AddMesh(mesh, PrintMeshOptions.Default());

            // create settings
            //MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2);
            //PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus);
            //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2);
            RepRapSettings settings = new RepRapSettings(RepRap.Models.Unknown);

            // do slicing
            MeshPlanarSlicer slicer = new MeshPlanarSlicer()
            {
                LayerHeightMM = settings.LayerHeightMM
            };

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

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

            if (printGen.Generate())
            {
                // export gcode
                GCodeFile gcode = printGen.Result;
                using (StreamWriter w = new StreamWriter("c:\\demo\\cone.gcode")) {
                    StandardGCodeWriter writer = new StandardGCodeWriter();
                    writer.WriteFile(gcode, w);
                }
            }
        }
示例#5
0
        public async Task <bool> Slice(IEnumerable <IObject3D> printableItems, PrinterSettings printerSettings, string filePath, IProgress <ProgressStatus> progressReporter, CancellationToken cancellationToken)
        {
            using (var outputStream = File.OpenWrite(filePath))
            {
                var sourceMeshes = new List <DMesh3>();

                foreach (var item in printableItems.Where(d => d.MeshPath != null))
                {
                    string sourceFilePath = await item.ResolveFilePath(null, cancellationToken);

                    // Load Mesh
                    if (File.Exists(sourceFilePath))
                    {
                        var mesh = StandardMeshReader.ReadMesh(sourceFilePath);
                        if (mesh != null)
                        {
                            sourceMeshes.Add(mesh);
                        }

                        var printCenter = printerSettings.GetValue <Vector2>(SettingsKey.print_center);
                        ApplyTransform(mesh, item.WorldMatrix(), printCenter);
                    }
                }

                PrintSettings settings = LoadSettingsForPrinter(printerSettings);

                // Construct slicer
                var slicer = new GeometrySlicer();
                slicer.SliceMeshes(sourceMeshes, settings);

                bool valid = slicer.ExtractResultsIfValid(out PrintMeshAssembly meshes, out PlanarSliceStack slices);

                // Construct GCode generator
                var pathGenerator = new ToolpathGenerator();
                pathGenerator.CreateToolPaths(meshes, slices, settings);

                // Write GCode file
                var gcodeWriter = new StandardGCodeWriter();

                var streamWriter = new StreamWriter(outputStream);

                gcodeWriter.WriteFile(pathGenerator.CurrentGCode, streamWriter);

                return(true);
            }
        }
示例#6
0
        public static void CreateExpectedResult(TestContext context)
        {
            var generator = new EngineFFF().Generator;

            var directory        = TestDataPaths.GetTestDataDirectory(CaseName);
            var meshFilePath     = TestDataPaths.GetMeshFilePath(directory);
            var expectedFilePath = TestDataPaths.GetExpectedFilePath(directory);

            var parts = new[] {
                new Tuple <DMesh3, object>(StandardMeshReader.ReadMesh(meshFilePath), null)
            };

            var expectedResult = generator.GenerateGCode(parts, new GenericRepRapSettings(), out _, null, Console.WriteLine);

            using var w = new StreamWriter(expectedFilePath);
            var writer = new StandardGCodeWriter();

            writer.WriteFile(expectedResult, w);
        }
示例#7
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);
        }
    }
示例#8
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);
        }
示例#9
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);
            }
        }
示例#10
0
        static string GenerateGCodeForMeshes(PrintMeshAssembly meshes)
        {
            bool ENABLE_SUPPORT_ZSHIFT = true;

            // configure settings
            //MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2);
            //FlashforgeSettings settings = new FlashforgeSettings(Flashforge.Models.CreatorPro);
            //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2);
            PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus);

            //PrusaSettings settings = new PrusaSettings(Prusa.Models.i3_MK3);

            //settings.ExtruderTempC = 215;
            //settings.Machine.NozzleDiamMM = 0.4;
            settings.Shells = 2;
            settings.InteriorSolidRegionShells = 0;
            settings.SparseLinearInfillStepX   = 5;
            //settings.SolidFillNozzleDiamStepX = 0;
            //settings.SolidFillBorderOverlapX = 0;
            //settings.SparseFillBorderOverlapX = 0;
            settings.ClipSelfOverlaps = false;
            //settings.RoofLayers = settings.FloorLayers = 0;
            //settings.LayerRangeFilter = new Interval1i(245, 255);
            //settings.LayerRangeFilter = new Interval1i(0, 0);

            settings.EnableBridging = true;

            settings.GenerateSupport         = false;
            settings.EnableSupportShell      = true;
            settings.SupportMinZTips         = false;
            settings.SupportSolidSpace       = 0.35;
            settings.SupportOverhangAngleDeg = 25;

            //settings.OuterShellLast = true;
            //settings.Shells = 0;

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

            settings.StartLayers        = 0;
            settings.StartLayerHeightMM = 0.3;


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

            LastSettings = settings.CloneAs <SingleMaterialFFFSettings>();

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

            // slice meshes
            MeshPlanarSlicer slicer = new MeshPlanarSlicer()
            {
                LayerHeightMM = settings.LayerHeightMM
            };

            if (settings.StartLayers > 0)
            {
                int    start_layers       = settings.StartLayers;
                double std_layer_height   = settings.LayerHeightMM;
                double start_layer_height = settings.StartLayerHeightMM;
                slicer.LayerHeightF = (layer_i) => {
                    return((layer_i < start_layers) ? start_layer_height : std_layer_height);
                };
            }

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

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

            // run print generator
            SingleMaterialFFFPrintGenerator printGen =
                new SingleMaterialFFFPrintGenerator(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 ISailfishSettings)
            {
                System.Diagnostics.Process.Start(GPX_PATH, (settings as ISailfishSettings).GPXModelFlag + " -p " + sWritePath);
            }

            View.PathDiameterMM = (float)settings.Machine.NozzleDiamMM - 0.005f;

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

            return(sWritePath);
        }
示例#11
0
        static string GenerateGCodeForMeshes(PrintMeshAssembly meshes)
        {
            AxisAlignedBox3d bounds = meshes.TotalBounds;
            double           top_z  = bounds.Depth;

            // configure settings
            RepRapSettings settings = new RepRapSettings(RepRap.Models.Unknown);

            settings.GenerateSupport = false;
            settings.EnableBridging  = false;

            int nSpeed = 1200;  // foam

            //int nSpeed = 700;   // wood

            settings.RapidTravelSpeed     = nSpeed;
            settings.RapidExtrudeSpeed    = nSpeed;
            settings.CarefulExtrudeSpeed  = nSpeed;
            settings.OuterPerimeterSpeedX = 1.0;
            settings.ZTravelSpeed         = nSpeed;
            settings.RetractSpeed         = nSpeed;

            settings.LayerHeightMM        = 4.0;
            settings.Machine.NozzleDiamMM = 6.35;

            settings.Machine.BedSizeXMM = 240;
            settings.Machine.BedSizeYMM = 190;

            settings.RetractDistanceMM = 1;
            settings.EnableRetraction  = true;

            settings.ShellsFillNozzleDiamStepX = 0.5;
            settings.SolidFillNozzleDiamStepX  = 0.9;
            settings.SolidFillBorderOverlapX   = 0.5;

            LastSettings = settings.CloneAs <SingleMaterialFFFSettings>();

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

            // slice meshes
            MeshPlanarMillSlicer slicer = new MeshPlanarMillSlicer()
            {
                LayerHeightMM     = settings.LayerHeightMM,
                ToolDiameter      = settings.Machine.NozzleDiamMM,
                ExpandStockAmount = 0.4 * settings.Machine.NozzleDiamMM
            };

            slicer.Add(meshes);
            MeshPlanarMillSlicer.Result sliceResult = slicer.Compute();
            PlanarSliceStack            slices      = sliceResult.Clearing;

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

            ToolpathSet accumPaths;
            GCodeFile   genGCode = generate_cnc_test(sliceResult, settings, out accumPaths);

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

            string sWritePath          = "../../../sample_output/generated.nc";
            StandardGCodeWriter writer = new StandardGCodeWriter()
            {
                CommentStyle = StandardGCodeWriter.CommentStyles.Bracket
            };

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

            //DMesh3 tube_mesh = GenerateTubeMeshesForGCode(sWritePath, settings.Machine.NozzleDiamMM);
            DMesh3 tube_mesh = GenerateTubeMeshesForGCode(sWritePath, 0.4);

            StandardMeshWriter.WriteMesh("../../../sample_output/generated_tubes.obj", tube_mesh, WriteOptions.Defaults);

            if (SHOW_RELOADED_GCODE_PATHS == false)
            {
                View.SetPaths(accumPaths, settings);
                View.PathDiameterMM = (float)settings.Machine.NozzleDiamMM;
            }


            slices.Add(sliceResult.HorizontalFinish.Slices);
            slices.Slices.Sort((a, b) => { return(a.Z.CompareTo(b.Z)); });
            View.SetSlices(slices);
            View.CurrentLayer = slices.Slices.Count - 1;

            return(sWritePath);
        }
示例#12
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);
        }