diff --git a/CustomWidgets/ExportPrintItemWindow.cs b/CustomWidgets/ExportPrintItemWindow.cs index 9aa5d389f..7fd4b8a8a 100644 --- a/CustomWidgets/ExportPrintItemWindow.cs +++ b/CustomWidgets/ExportPrintItemWindow.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Text; using System.Collections.Generic; using System.Globalization; @@ -121,6 +122,20 @@ namespace MatterHackers.MatterControl }); middleRowContainer.AddChild(exportToSdCard); } + + if (ActiveSliceSettings.Instance.IsMakerbotGCodeFlavor() && !PrinterConnectionAndCommunication.Instance.PrinterIsPrinting) + { + string exportAsX3GText = "Export as X3G".Localize(); + Button exportAsX3G = textImageButtonFactory.Generate(exportAsX3GText); + exportAsX3G.HAnchor = HAnchor.ParentLeft; + exportAsX3G.Cursor = Cursors.Hand; + exportAsX3G.Click += new ButtonBase.ButtonEventHandler((object sender, MouseEventArgs e) => + { + UiThread.RunOnIdle(ExportX3G_Click); + + }); + middleRowContainer.AddChild(exportAsX3G); + } } middleRowContainer.AddChild(new VerticalSpacer()); @@ -312,6 +327,45 @@ namespace MatterHackers.MatterControl } } + + void ExportX3G_Click(object state) + { + SaveFileDialogParams saveParams = new SaveFileDialogParams("Export GCode|*.gcode", title: "Export GCode"); + saveParams.Title = "MatterControl: Export File"; + saveParams.ActionButtonLabel = "Export"; + + System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams); + if (streamToSaveTo != null) + { + streamToSaveTo.Close (); + + pathAndFilenameToSave = saveParams.FileName; + string extension = Path.GetExtension(pathAndFilenameToSave); + if(extension == "") + { + File.Delete(pathAndFilenameToSave); + pathAndFilenameToSave += ".gcode"; + } + + if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL") + { + Close(); + SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper); + printItemWrapper.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents); + + /*ProcessStartInfo exportX3GProcess = new ProcessStartInfo(printItemWrapper.PrintItem.Name); + exportX3GProcess.UseShellExecute = true; + exportX3GProcess.FileName = "C:\\Users\\Matter Hackers 1\\GPX\\gpx-win32-1.3\\gpx-win32-1.3\\gpx.exe"; + Process.Start(exportX3GProcess);*/ + } + else if (partIsGCode) + { + Close(); + SaveGCodeToNewLocation(printItemWrapper.FileLocation, pathAndFilenameToSave); + } + } + } + private void SaveGCodeToNewLocation(string source, string dest) { if (ActivePrinterProfile.Instance.DoPrintLeveling) @@ -430,6 +484,10 @@ namespace MatterHackers.MatterControl printItemWrapper.SlicingDone.UnregisterEvent(sliceItem_Done, ref unregisterEvents); SaveGCodeToNewLocation(sliceItem.GetGCodePathAndFileName(), pathAndFilenameToSave); + ProcessStartInfo exportX3GProcess = new ProcessStartInfo(printItemWrapper.PrintItem.Name); + exportX3GProcess.UseShellExecute = true; + exportX3GProcess.FileName = "C:\\Users\\Matter Hackers 1\\GPX\\gpx-win32-1.3\\gpx-win32-1.3\\gpx.exe"; + Process.Start(exportX3GProcess); } } } diff --git a/MatterControl.csproj b/MatterControl.csproj index d7ecaabce..049f84e92 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -38,7 +38,6 @@ true 8.0.30703 2.0 - 0.8.2 True @@ -48,7 +47,6 @@ TRACE;DEBUG;USE_OPENGL;IS_WINDOWS;IS_WINDOWS_FORMS prompt 4 - false x86 @@ -244,6 +242,11 @@ + + + + + @@ -389,7 +392,7 @@ {865172A0-A1A9-49C2-9386-F2FDB4E141B7} MatterControlPluginSystem - + {657DBC6D-C3EA-4398-A3FA-DDB73C14F71B} Agg diff --git a/PrintQueue/OptionsMenu/QueueOptionsMenu.cs b/PrintQueue/OptionsMenu/QueueOptionsMenu.cs index b588e2db0..61acbe6df 100644 --- a/PrintQueue/OptionsMenu/QueueOptionsMenu.cs +++ b/PrintQueue/OptionsMenu/QueueOptionsMenu.cs @@ -94,6 +94,8 @@ namespace MatterHackers.MatterControl.PrintQueue menuItems.Add(new Tuple>(LocalizedString.Get(" Export to Zip"), exportQueueToZipMenu_Click)); menuItems.Add(new Tuple>("GCode", null)); menuItems.Add(new Tuple>(LocalizedString.Get(" Export to Folder"), exportGCodeToFolderButton_Click)); + menuItems.Add(new Tuple>("X3G", null)); + menuItems.Add(new Tuple>(LocalizedString.Get("Export to Folder"), exportX3GButton_Click)); if (ActiveSliceSettings.Instance.HasSdCardReader()) { @@ -196,6 +198,20 @@ namespace MatterHackers.MatterControl.PrintQueue return true; } + bool exportX3GButton_Click() + { + if (ActivePrinterProfile.Instance.ActivePrinter == null) + { + UiThread.RunOnIdle(MustSelectPrinterMessage); + } + else + { + UiThread.RunOnIdle(SelectLocationToExportGCode); + } + return true; + + } + void ExportToFolderFeedbackWindow_Closed(object sender, EventArgs e) { this.exportingWindow = null; diff --git a/SlicerConfiguration/ActiveSliceSettings.cs b/SlicerConfiguration/ActiveSliceSettings.cs index e92d043ca..397f0946a 100644 --- a/SlicerConfiguration/ActiveSliceSettings.cs +++ b/SlicerConfiguration/ActiveSliceSettings.cs @@ -200,6 +200,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration return GetActiveValue("has_sd_card_reader") == "1"; } + public bool IsMakerbotGCodeFlavor() + { + return GetActiveValue("gcode_flavor") == "makerbot"; + } + public bool HasHeatedBed() { return GetActiveValue("has_heated_bed") == "1"; diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index 4df3fd1c7..e97f61bec 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -2532,3 +2532,9 @@ Translated:The angle the support infill will be drawn. English:Infill Angle Translated:Infill Angle +English:Export to Folder +Translated:Export to Folder + +English:Export as X3G +Translated:Export as X3G +