public static bool STL(PartDocument part, string path) { part.ExportData(path, "stl"); return(true); }
internal string SaveSurfaceAndFixedPoints(ref List <double[]> FixedPoints, ref double[] oPlane) { string StlPath = System.IO.Path.GetTempPath() + "STLFileBlankCalculator";; oPartDoc = (PartDocument)CATIA.ActiveDocument; oSel = oPartDoc.Selection; oSpa = (SPAWorkbench)oPartDoc.GetWorkbench("SPAWorkbench"); FixedPoints = new List <double[]>(); oSel.Clear(); oSel.Add(SelectSurface("Selecione qual a superficie que pretende planificar. Esc para sair.")); oSel.Copy(); oSel.Clear(); PartDocument NewPart = (PartDocument)CATIA.Documents.Add("Part"); NewPart.Selection.Clear(); NewPart.Selection.Add(NewPart.Part); NewPart.Selection.PasteSpecial("CATPrtResultWithOutLink"); if (System.IO.File.Exists(StlPath + ".stl")) { System.IO.File.Delete(StlPath + ".stl"); } NewPart.Selection.Clear(); NewPart.Part.Update(); CATIA.DisplayFileAlerts = false; NewPart.ExportData(StlPath, "stl"); NewPart.Close(); CATIA.DisplayFileAlerts = true; object[] Vec = new object[3]; oSel.Clear(); Reference Ref1 = SelectPoint("Selecione o conjunto de pontos fixos. Esc para sair."); oSel.Clear(); if (Ref1 == null) { Environment.Exit(0); } oSpa.GetMeasurable(Ref1).GetPoint(Vec); FixedPoints.Add(new double[] { (double)Vec[0], (double)Vec[1], (double)Vec[2] }); do { Ref1 = SelectPoint("Selecione o conjunto de pontos fixos (" + FixedPoints.Count + " selecionados). Esc para terminar."); oSel.Clear(); if (Ref1 == null) { break; } oSpa.GetMeasurable(Ref1).GetPoint(Vec); FixedPoints.Add(new double[] { (double)Vec[0], (double)Vec[1], (double)Vec[2] }); } while (true); if (FixedPoints.Count == 0) { Environment.Exit(0); } oSel.Clear(); oPartDoc.Part.Update(); System.Windows.Forms.Application.DoEvents(); System.Threading.Thread.Sleep(500); Vec = new object[9]; Reference Ref2 = SelectPlane("Selecione qual o plano do planificado. Esc para terminar."); oSel.Clear(); oSpa.GetMeasurable(Ref2).GetPlane(Vec); oPlane = new double[] { (double)Vec[0], (double)Vec[1], (double)Vec[2], (double)Vec[3], (double)Vec[4], (double)Vec[5], (double)Vec[6], (double)Vec[7], (double)Vec[8] }; return(StlPath + ".stl"); }