Simply sharing
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Greetings all,
I simply wanted to share some code with you in hopes that it might help you in some way.
It is derived from various sources here in this forum as well as in Google-land.
I am very new to iLogic, so this is in no way 'advanced' code and very little of it is 'original' coding on my part.
But in all the searching I had to do to get this far, I thought it only kind to share it with others.
The rule:
Save BOM To PDF
The parts list is exported to a pdf, formatted using a predetermined xls template and saved in the same folder as the idw.
It also comes with extra code to append the file name with the current Revision (if indeed there is one).
**Currently no error trap to check for the presence of a parts list**
Now, I know Inventor allows other ways to export to pdf, but our company really wanted to have the extra options, control and a 'one button solution' for this seemingly simple task.
The rule exists and can therefore be placed as a button on a form that controls all req'd information for out drawing title blocks.
(We no longer have to access iProperties dialog...ever...and that is wonderful lol)
Ok, I will shut up now 🙂
Here is the code - peace!
If dorev = 0 Then altName = ".pdf" Else altName = " (REV " & iProperties.Value("Project","Revision Number") & ")" & ".pdf" pathfname = ThisDoc.PathAndFileName(False) dorev = iProperties.Value("Project","Revision Number") If dorev = 0 Then altName = " BOM" Else altName = " BOM (REV " & iProperties.Value("Project","Revision Number") & ")" Dim oDoc As Inventor.DrawingDocument oDoc = ThisDoc.Document Dim oSheet As Inventor.Sheet 'oSheet = oDoc.Sheets(1) ' first sheet oSheet = oDoc.Sheets("1:1") ' sheet by name ' say there is a Partslist on the sheet. Dim oPartslist As PartsList oPartslist = oSheet.PartsLists(1) ' create a new NameValueMap object oOptions = ThisApplication.TransientObjects.CreateNameValueMap 'specify an existing template file 'to use For formatting colors, fonts, etc oOptions.Value("Template") = "D:\Path to you're template file goes here\whatever\whenever\My BOM Template.xls" 'choose to autofit the column width in the xls file oOptions.Value("AutoFitColumnWidth") = True ' export the Partslist to Excel. ' folderName = "C:\temp" folderName = ThisDoc.Path 'oPartslist.Export(folderName & "\BOM.xls", PartsListFileFormatEnum.kMicrosoftExcel, oOptions) oPartslist.Export(pathfname & altName, PartsListFileFormatEnum.kMicrosoftExcel, oOptions)