- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I came across the below code and thought all my wishes had been granted. However, as with every other forum post I've seen up to know an issue is the exported columns are rearranged into alphabetical order. Is this something anyone has been able to figure out?
'Adapted from Inventor API Samples by Clint Brown @ClintCadline
'Originally posted on Cadline Community https://www.cadlinecommunity.co.uk/hc/en-us/articles/212849309
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject Then
MessageBox.Show("You need to be in an Assembly to Export a BOM", "Cadline: iLogic - BOM Publisher")
Return
End If
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
'==========================================================================================
'You can change the output path by editing oPATH below
oPATH = ("c:\temp\") 'If you change this, remember to keep a \ at the end
'==========================================================================================
'STRUCTURED BoM ===========================================================================
' the structured view to 'all levels'
oBOM.StructuredViewFirstLevelOnly = False
' Make sure that the structured view is enabled.
oBOM.StructuredViewEnabled = True
Dim oStructuredBOMView As BOMView
oStructuredBOMView = oBOM.BOMViews.Item("Structured")
' Export the BOM view to an Excel file
oStructuredBOMView.Export (oPATH + ThisDoc.FileName(False) + ".xls", kMicrosoftExcelFormat)
'==========================================================================================
'PARTS ONLY BoM ===========================================================================
'' Make sure that the parts only view is enabled.
'oBOM.PartsOnlyViewEnabled = True
'Dim oPartsOnlyBOMView As BOMView
'oPartsOnlyBOMView = oBOM.BOMViews.Item("Parts Only")
'' Export the BOM view to an Excel file
'oPartsOnlyBOMView.Export (oPATH + "BOM-PartsOnly.xls", kMicrosoftExcelFormat)
'==========================================================================================
i = MessageBox.Show("Preview the BOM?", "Cadline: iLogic - BOM Publisher",MessageBoxButtons.YesNo)
If i = vbYes Then : launchviewer = 1 : Else : launchviewer = 0 : End If
If launchviewer = 1 Then ThisDoc.Launch(oPATH + ThisDoc.FileName(False) + ".xls")I'm also interested in what export options I can use and any pre-formatting I can do with illogic.
Some of the typical tasks I do within the bom editor before exporting manually.
First thing is check both bom types are enabled
Import my xml for column structure
Structured bom
Renumber items from 1
Check all levels is selected (I see it’s an option in the above code but I don’t know if that’s an issue if it wasn’t set as that)
Update mass (which I assume updates in parts only to)
Parts only
Sort by category then by part number in ascending order
Then I export both boms manually redirecting to a specific folder and using a temp name.
With both worksheets open in excel I combine the parts only with the structured and go about the usual formatting such auto-width deleting the tabs I don’t require and putting a border around what’s left. I then go about splitting the data it into multiple sheets by copying the sheet and further deleting the columns and rows not relevant to that specific sheet.
At the moment I’ve been putting together an excel template to save myself some time in formatting and creating the sheet. I’m hoping to automate as much as possible including the splitting of the data. I’m between splitting my data using a macro or making my structured and pt only tables into existing connection tables in the other sheets so the information updates as per originals. Obviously i have to get my data from inventor to excel which will leave me with two spreadsheet so at the point am i able to call on my template and copy the exported data from row A2 so it excludes headings and paste into correct sheet of template in A2 (which is part of a pre-made table)
I suppose my real question is what are my limitations using illogic to export my boms and at what what point will I have to rely on excel vba.
Solved! Go to Solution.