
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm interested in exporting a parts list from either an assembly or drawing. I've tried various codes and approaches but I can't seem to get it right.
Firstly, the .idw parts list approach only allows you to export columns that are present in your parts list.
The .iam BOM approach has no documentation on formatting (changing the table name of the spreadsheet etc)
Ideally I would lik to be able to export a BOM from an assembly, into perhaps a template, then to have the code change the tab name to the designer iproperty from the assembly file.
Then for a dialogue to ask for a quantity and populate this number into a specified column in the output spreadsheet.
It might be a bit much but so far all I have is the code below:
-------------------------------------------------------------------------------------------------------------
'BOM Publisher
oDoc = ThisDoc.ModelDocument
If oDoc.DocumentType = kPartDocumentObject Then
MessageBox.Show("You need to be in an Assembly to Export a BOM", "Databar: iLogic - BOM Publisher")
Return
End If
oDoc = ThisApplication.ActiveDocument
Dim oBOM As BOM
oBOM = oDoc.ComponentDefinition.BOM
'Options.Value("Author") = iProperties.Value("Summary", "Author")
'==========================================================================================
'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)
oPartsOnlyBOMView.Export (oPATH + ThisDoc.FileName(False) + " GA" + ".xls", kMicrosoftExcelFormat)
'==========================================================================================
i = MessageBox.Show("Preview the BOM?", "Databar: 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) + " GA" + ".xls")
---------------------------------------------------------------------------------
Thanks in advance,
Ahmed.
Solved! Go to Solution.