diff --git a/CatiaNetTest/AssemblyTiers2.vb b/CatiaNetTest/AssemblyTiers2.vb index f898c914cb515dc28f6a23a71f3faf099e2bc00f..2fd78a982435e2d8b9990483df317eeb745ede18 100644 --- a/CatiaNetTest/AssemblyTiers2.vb +++ b/CatiaNetTest/AssemblyTiers2.vb @@ -188,6 +188,9 @@ Public Class AssemblyTiers2 MsgBox("Bounding box calculation took " & CStr(BBSecondsElapsed) & " seconds") Debug.Print("Number of faces in assembly: " & CStr(intNumFaces)) + 'Export BB volumes of parts to Excel + ExportBBVolumes() + 'Collision parameters If bAutomaticStep Then Dim dGeomMean As Double @@ -1875,6 +1878,33 @@ Finish: Return True End Function + Sub ExportBBVolumes() + 'Use Excel + Dim objExcel As Microsoft.Office.Interop.Excel.Application + objExcel = CreateObject("Excel.Application") + objExcel.Visible = True + objExcel.Workbooks.Add() + objExcel.ActiveWorkbook.Sheets.Add.Name = "BB Volumes" + Dim objSheet1 As Object + objSheet1 = objExcel.ActiveWorkbook.Worksheets(1) + 'Write data + objSheet1.Cells(1, 1).Value = "Product" + objSheet1.Cells(1, 2).Value = "BB volume" + For int_i = 0 To cRelevantProducts.Count - 1 + Dim dPartBBVolume As Double + dPartBBVolume = (aPartBBGlob(int_i, 0) - aPartBBGlob(int_i, 1)) * (aPartBBGlob(int_i, 2) - aPartBBGlob(int_i, 3)) * (aPartBBGlob(int_i, 4) - aPartBBGlob(int_i, 5)) + objSheet1.Cells(int_i + 2, 1).Value = cRelevantProducts.Item(int_i).Name + objSheet1.Cells(int_i + 2, 2).Value = dPartBBVolume + Next int_i + 'Save and close excel workbook + Dim xlsFileName As String = CATIA.ActiveDocument.Name + objExcel.ActiveWorkbook.SaveAs(Filename:=xlsPath & xlsFileName & "_BB Volumes.xlsx") + objExcel.ActiveWorkbook.Close(SaveChanges:=True) + 'close the excel application + objExcel.Quit() + ReleaseObject(objExcel) + End Sub + Private Sub ReleaseObject(ByVal obj As Object) Try Dim intRel As Integer = 0