public FormMain(bool showRoot) { // set static instance Instance = this; try { InitializeComponent(); Text = Application.ProductName; // set export application ApplicationAvailabilityChecker.AppendApplication("PicGEOM", Pic.Factory2D.Control.Properties.Settings.Default.FileOutputAppDES); ApplicationAvailabilityChecker.AppendApplication("PicDecoup", Pic.Factory2D.Control.Properties.Settings.Default.FileOutputAppPicDecoupeDES); ApplicationAvailabilityChecker.AppendApplication("Picador3D", Pic.Factory2D.Control.Properties.Settings.Default.FileOutputAppPic3DDES); } catch (Exception ex) { _log.Error(ex.ToString()); } }
private void OnGeneratePic3D(object sender, EventArgs e) { Pic.Plugin.Component comp = pluginViewCtrl.Component; if (!pluginViewCtrl.Visible || null == comp || !comp.IsSupportingAutomaticFolding) { return; } // get documents at the same lavel if (!(treeView.SelectedNode.Tag is NodeTag nodeTag)) { return; } PPDataContext db = new PPDataContext(); Pic.DAL.SQLite.TreeNode treeNode = Pic.DAL.SQLite.TreeNode.GetById(db, nodeTag.TreeNode); List <Document> des3Docs = treeNode.GetBrothersWithExtension(db, "des3"); if (0 == des3Docs.Count) { MessageBox.Show("Missing des3 for sample pattern files"); return; } List <string> filePathes = new List <string>(); foreach (Document d in des3Docs) { filePathes.Add(d.File.Path(db)); } SaveFileDialog fd = new SaveFileDialog { Filter = "Picador 3D files (*.des3)|*.des3|All files (*.*)|*.*", FilterIndex = 0, DefaultExt = "des3", FileName = treeNode.Name + ".des3" }; if (DialogResult.OK == fd.ShowDialog()) { string des3File = fd.FileName; string desFile = Path.ChangeExtension(des3File, "des"); string xmlFile = Path.ChangeExtension(des3File, "xml"); string currentDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); // generate des file Export(desFile); // reference point double thickness = 0.0; Sharp3D.Math.Core.Vector2D v = Sharp3D.Math.Core.Vector2D.Zero; if (pluginViewCtrl.GetReferencePointAndThickness(ref v, ref thickness)) { // #### job file Pic3DExporter.Job job = new Pic3DExporter.Job(); // **** FILES BEGIN **** job.Pathes.Add(new Pic3DExporter.PathItem() { pathID = "FID-1", path = desFile, type = Pic3DExporter.pathType.FILE }); job.Pathes.Add(new Pic3DExporter.PathItem() { pathID = "FID-2", path = des3File, type = Pic3DExporter.pathType.FILE }); int fid = 2; foreach (string filePath in filePathes) { job.Pathes.Add(new Pic3DExporter.PathItem() { pathID = string.Format("FID-{0}", ++fid), path = filePath, type = Pic3DExporter.pathType.FILE }); } // **** FILES END **** // **** TASKS BEGIN **** // DES -> DES3 Pic3DExporter.task_2D_TO_DES3 task_2D_to_DES3 = new Pic3DExporter.task_2D_TO_DES3() { id = "TID-1" }; task_2D_to_DES3.Inputs.Add(new Pic3DExporter.PathRef() { pathID = "FID-1", role = "input des", deleteAfterUsing = false }); task_2D_to_DES3.Outputs.Add(new Pic3DExporter.PathRef() { pathID = "FID-2", role = "output des3", deleteAfterUsing = false }); task_2D_to_DES3.autoparameters.thicknessSpecified = true; task_2D_to_DES3.autoparameters.thickness = (float)thickness; task_2D_to_DES3.autoparameters.foldPositionSpecified = true; task_2D_to_DES3.autoparameters.foldPosition = (float)0.5; task_2D_to_DES3.autoparameters.pointRef.Add((float)v.X); task_2D_to_DES3.autoparameters.pointRef.Add((float)v.Y); fid = 2; foreach (string filePath in filePathes) { task_2D_to_DES3.autoparameters.modelFiles.Add( new Pic3DExporter.PathRef() { pathID = string.Format("FID-{0}", ++fid), role = "model files", deleteAfterUsing = false }); } job.Tasks.Add(task_2D_to_DES3); // **** TASKS END **** job.SaveToFile(xmlFile); // #### execute Pic3DExporter string exePath = Pic3DExporterPath; if (!System.IO.File.Exists(exePath)) { MessageBox.Show(string.Format("File {0} could not be found!", exePath)); return; } var procExporter = new Process { StartInfo = new ProcessStartInfo { FileName = exePath, Arguments = string.Format(" -t \"{0}\"", xmlFile), UseShellExecute = false, CreateNoWindow = true, RedirectStandardOutput = false, RedirectStandardError = false } }; procExporter.Start(); procExporter.WaitForExit(); Thread.Sleep(1000); // delete xml task file try { if (!Settings.Default.ShowLogConsole) { System.IO.File.Delete(xmlFile); } } catch (Exception) { } } if (System.IO.File.Exists(des3File)) { if (ApplicationAvailabilityChecker.IsAvailable("Picador3D")) { var procPic3D = new Process { StartInfo = new ProcessStartInfo { FileName = des3File, UseShellExecute = true, CreateNoWindow = false, Verb = "open", WindowStyle = ProcessWindowStyle.Normal } }; procPic3D.Start(); } } else { MessageBox.Show(string.Format("Failed to generate {0}", des3File)); } } }