public void RestoreConfigs() { if (profileConfig != null) profileConfig.writeOriginal(); if (exportConfig != null) exportConfig.writeOriginal(); if (extrusionConfig != null) extrusionConfig.writeOriginal(); if (multiplyConfig != null) multiplyConfig.writeOriginal(); profileConfig = null; exportConfig = null; extrusionConfig = null; multiplyConfig = null; }
public void RunSlice(string file, string profile) { if (procConvert != null) { MessageBox.Show(Trans.T("L_SKEIN_STILL_RUNNING") /*"Last slice job still running. Slicing of new job is canceled."*/,Trans.T("L_ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string py = PyPy; if (py == null) { MessageBox.Show(Trans.T("L_PYPY_NOT_FOUND"), Trans.T("L_ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string craft = findCraft(); if (craft == null) { MessageBox.Show(Trans.T("L_SKEINCRAFT_NOT_FOUND"), Trans.T("L_ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string profdir = findSkeinforgeProfiles(); if (profdir == null) { MessageBox.Show(Trans.T("L_SKEINCRAFT_PROFILES_NOT_FOUND"), Trans.T("L_ERROR"), MessageBoxButtons.OK, MessageBoxIcon.Error); return; } profileConfig = new SkeinConfig(Path.Combine(profdir,"skeinforge_profile.csv")); extrusionConfig = new SkeinConfig(Path.Combine(profdir,"extrusion.csv")); exportConfig = new SkeinConfig(Path.Combine(profdir,"extrusion" + Path.DirectorySeparatorChar + profile + Path.DirectorySeparatorChar + "export.csv")); multiplyConfig = new SkeinConfig(Path.Combine(profdir,"extrusion" + Path.DirectorySeparatorChar + profile + Path.DirectorySeparatorChar + "multiply.csv")); // Set profile to extrusion /* cutting False extrusion True milling False winding False */ profileConfig.setValue("cutting", "False"); profileConfig.setValue("milling", "False"); profileConfig.setValue("extrusion", "True"); profileConfig.setValue("winding", "False"); profileConfig.writeModified(); // Set used profile extrusionConfig.setValue("Profile Selection:", profile); extrusionConfig.writeModified(); // Set export to correct values exportConfig.setValue("Activate Export", "True"); exportConfig.setValue("Add Profile Extension", "False"); exportConfig.setValue("Add Profile Name to Filename", "False"); exportConfig.setValue("Add Timestamp Extension", "False"); exportConfig.setValue("Add Timestamp to Filename", "False"); exportConfig.setValue("Add Description to Filename", "False"); exportConfig.setValue("Add Descriptive Extension", "False"); exportConfig.writeModified(); multiplyConfig.setValue("Activate Multiply:", "False"); multiplyConfig.setValue("Activate Multiply: ", "False"); multiplyConfig.setValue("Activate Multiply", "False"); multiplyConfig.writeModified(); string target = StlToGCode(file); if (File.Exists(target)) File.Delete(target); procConvert = new Process(); try { SlicingInfo.Start(name); SlicingInfo.SetAction(Trans.T("L_SLICING_STL_FILE...")); //"Slicing STL file ..."); slicefile = file; procConvert.EnableRaisingEvents = true; procConvert.Exited += new EventHandler(ConversionExited); procConvert.StartInfo.FileName = Main.IsMono ? py : wrapQuotes(py); procConvert.StartInfo.Arguments = wrapQuotes(craft) + " " + wrapQuotes(file); procConvert.StartInfo.UseShellExecute = false; procConvert.StartInfo.WorkingDirectory = textWorkingDirectory.Text; procConvert.StartInfo.RedirectStandardOutput = true; procConvert.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler); procConvert.StartInfo.RedirectStandardError = true; procConvert.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler); procConvert.Start(); // Start the asynchronous read of the standard output stream. procConvert.BeginOutputReadLine(); procConvert.BeginErrorReadLine(); //Main.main.tab.SelectedTab = Main.main.tabPrint; } catch (Exception e) { Main.conn.log(e.ToString(), false, 2); RestoreConfigs(); } }
public void RunSlice(string file,string profile) { if (procConvert != null) { MessageBox.Show("Last slice job still running. Slicing of new job is canceled.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } profileConfig = new SkeinConfig(BasicConfiguration.basicConf.SkeinforgeProfileDir + Path.DirectorySeparatorChar + "skeinforge_profile.csv"); extrusionConfig = new SkeinConfig(BasicConfiguration.basicConf.SkeinforgeProfileDir+Path.DirectorySeparatorChar+"extrusion.csv"); exportConfig = new SkeinConfig(BasicConfiguration.basicConf.SkeinforgeProfileDir + Path.DirectorySeparatorChar + "extrusion" + Path.DirectorySeparatorChar + profile + Path.DirectorySeparatorChar + "export.csv"); // Set profile to extrusion /* cutting False extrusion True milling False winding False */ profileConfig.setValue("cutting", "False"); profileConfig.setValue("milling", "False"); profileConfig.setValue("extrusion", "True"); profileConfig.setValue("winding", "False"); profileConfig.writeModified(); // Set used profile extrusionConfig.setValue("Profile Selection:", profile); extrusionConfig.writeModified(); // Set export to correct values exportConfig.setValue("Activate Export", "True"); exportConfig.setValue("Add Profile Extension", "False"); exportConfig.setValue("Add Timestamp Extension", "False"); exportConfig.writeModified(); string target = StlToGCode(file); if (File.Exists(target)) File.Delete(target); procConvert = new Process(); try { SlicingInfo.Start("Skeinforge"); SlicingInfo.SetAction("Slicing STL file ..."); slicefile = file; procConvert.EnableRaisingEvents = true; procConvert.Exited += new EventHandler(ConversionExited); procConvert.StartInfo.FileName = Main.IsMono ? PyPy : wrapQuotes(PyPy); procConvert.StartInfo.Arguments = wrapQuotes(textSkeinforgeCraft.Text) + " " + wrapQuotes(file); procConvert.StartInfo.UseShellExecute = false; procConvert.StartInfo.WorkingDirectory = textWorkingDirectory.Text; procConvert.StartInfo.RedirectStandardOutput = true; procConvert.OutputDataReceived += new DataReceivedEventHandler(OutputDataHandler); procConvert.StartInfo.RedirectStandardError = true; procConvert.ErrorDataReceived += new DataReceivedEventHandler(OutputDataHandler); procConvert.Start(); // Start the asynchronous read of the standard output stream. procConvert.BeginOutputReadLine(); procConvert.BeginErrorReadLine(); //Main.main.tab.SelectedTab = Main.main.tabPrint; } catch (Exception e) { Main.conn.log(e.ToString(), false, 2); } }