Hi MisterZS,
Please find a sample code in the following. Which exports BOM to 2 excels of "Structured" BOMviews and "Parts Only" BOMViews. Then copies one excel data to another excel. The code can be modified as per requirement.
' Set a reference to the assembly document.
' This assumes an assembly document is active.
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
' Set the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False
' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
' Set a reference to the "Structured" BOMView
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")
' Export the BOM view to an Excel file
oStructuredBOMView.Export("C:\temp\BOM-StructuredAllLevels.xls", kMicrosoftExcelFormat)
' Make sure that the parts only view is enabled.
oBOM.PartsOnlyViewEnabled = True
' Set a reference to the "Parts Only" BOMView
Dim oPartsOnlyBOMView As BOMView
oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only")
' Export the BOM view to an Excel file
oPartsOnlyBOMView.Export("C:\temp\BOM-PartsOnly.xls", kMicrosoftExcelFormat)
GoExcel.Open("C:\temp\BOM-PartsOnly.xls")
wb = GoExcel.Application.ActiveWorkbook
ws = wb.WorkSheets.Add()
GoExcel.Save()
GoExcel.Close()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "A1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "A1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "B1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "B1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "C1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "C1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "D1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "D1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "E1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "E1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "F1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "F1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "G1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "G1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "H1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "H1", "")
GoExcel.Save()
GoExcel.CellValues("C:\temp\BOM-PartsOnly.xls", "Sheet2", "I1", "") = GoExcel.CellValues("C:\temp\BOM-StructuredAllLevels.xls", "Sheet1", "I1", "")
GoExcel.Save()
Thanks and regards,
CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network