here are my rules so far: (most parts I gathered on the forums)
create bom:
SyntaxEditor Code Snippet
iLogicVb.UpdateWhenDone = True
'ThisBOM.Export("Parts Only", "Bom353.xls", kMicrosoftExcelFormat)'ThisBOM.Export("Structured", "Bom631.xls", kTextFileTabDelimitedFormat)'ThisBOM.Export("Structured", ThisDoc.ChangeExtension(".mdb"), kMicrosoftAccessFormat)
' On Error Resume Next
' Set a reference to the drawing document. This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
'Set a reference to the active sheet.
Dim oSheet As Sheet
oSheet = oDrawDoc.ActiveSheet
' Set a reference to the first drawing view on the sheet. This assumes the first drawing view on the sheet is not a draft view.
Dim oDrawingView As DrawingView
oDrawingView = oSheet.DrawingViews(1)
' Set a reference to the sheet's border
Dim oBorder As Border
oBorder = oSheet.Border
Dim oPlacementPoint As Point2d
oPlacementPoint = ThisApplication.TransientGeometry.CreatePoint2d(0, 0)
iLogicVb.UpdateWhenDone = True
' Create the parts list.
Dim oPartsList As PartsList
'oPartsList = oSheet.PartsLists.Set(KPartsOnly)' oPartsList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint,)
PartList = oSheet.PartsLists.Add(oDrawingView, oPlacementPoint, PartsListLevelEnum.kPartsOnly)
'oPartsList = oSheet.PartsLists.Add(CurrView, oPt, kPartsOnly)
'oPartsList.Style = oDrawDoc.StylesManager.PartsListStyles.Item("Hoefnagels Small")
iLogicVb.UpdateWhenDone = True
iLogicVb.RunRule("export bom")
and export bom/ pdf:
SyntaxEditor Code Snippet
'start Of iLogic code----------------------------------------------------------------------------------'sort parts list
On Error Resume Next
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oPartsList1 As PartsList
oPartsList1 = oDrawDoc.ActiveSheet.PartsLists.Item(1)
'If oPartsList1 Is Nothing Then Resume Next
oPartsList1.Sort("TYPE")
'oPartsList1.Renumber'oPartsList1.SaveItemOverridesToBOM
'------------------------------------------------------------------------------------------------------------'Export Parts List
path_and_name = ThisDoc.PathAndFileName(False) ' without extension
Dim oDoc As Inventor.DrawingDocument
oDoc = ThisDoc.Document
Dim oSheet As Inventor.Sheet
'oSheet = oDoc.Sheets(1) ' first sheet
oSheet = oDoc.Sheets("Sheet:1") ' sheet by name
' say there is a Partslist on the sheet.
Dim oPartslist As PartsList
' say there is a Partslist on the sheet.
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") = "C:\Temp\PartListExport.xls"
'specify the columns to export
oOptions.Value("ExportedColumns") = "QTY;PART NUMBER;DESCRIPTION;LENGTH;TYPE"
'specify the start cell
oOptions.Value("StartingCell") = "A3"
'specify the XLS tab name'here the file name is used'oOptions.Value("TableName") = ThisDoc.FileName(False) 'without extension
'choose to include the parts list title row'in this example "Ye Old List of Parts" is written to the StartingCell
oOptions.Value("IncludeTitle") = True
'choose to autofit the column width in the xls file
oOptions.Value("AutoFitColumnWidth") = True
On Error Goto handleXLSLock
' export the Partslist to Excel with options
oPartslist.Export(path_and_name & ".xls", _
PartsListFileFormatEnum.kMicrosoftExcel, oOptions)
''Publish document.'' export the Partslist to Excel.'oPartslist.Export(path_and_name & ".xls",PartsListFileFormatEnum.kMicrosoftExcel)
'--------------------------------------------------------------------------------------------------------------------'set Drawn by name
iProperties.Value("Summary", "Author" ) = ThisApplication.GeneralOptions.UserName
'set date
iProperties.Value("Project", "Creation Date" ) = Now
InventorVb.DocumentUpdate()
'--------------------------------------------------------------------------------------------------------------------'Save PDF with options
path_and_namePDF = ThisDoc.PathAndFileName(False) ' without extension
PDFAddIn = ThisApplication.ApplicationAddIns.ItemById("{0AC6FD96-2F4D-42CE-8BE0-8AEA580399E4}")
oDocument = ThisApplication.ActiveDocument
oContext = ThisApplication.TransientObjects.CreateTranslationContext
oContext.Type = IOMechanismEnum.kFileBrowseIOMechanism
oOptions = ThisApplication.TransientObjects.CreateNameValueMap
oDataMedium = ThisApplication.TransientObjects.CreateDataMedium
If PDFAddIn.HasSaveCopyAsOptions(oDataMedium, oContext, oOptions) Then
'oOptions.Value("All_Color_AS_Black") = 0
oOptions.Value("Remove_Line_Weights") = 1
oOptions.Value("Vector_Resolution") = 400
oOptions.Value("Sheet_Range") = Inventor.PrintRangeEnum.kPrintAllSheets
'oOptions.Value("Custom_Begin_Sheet") = 2'oOptions.Value("Custom_End_Sheet") = 4
End If
'Set the destination file name
oDataMedium.FileName = path_and_namePDF & ".pdf"
On Error Goto handlePDFLock
'Publish document.
Call PDFAddIn.SaveCopyAs(oDocument, oContext, oOptions, oDataMedium)
'--------------------------------------------------------------------------------------------------------------------
MessageBox.Show("PDF and Parts list saved in local VaultWorkingFolder", "files saved",MessageBoxButtons.OK,MessageBoxIcon.Information)
Exit Sub
handlePDFLock:MessageBox.Show("PDF could not be saved, most likely someone else has it open", "No PDF for you" & ThisApplication.GeneralOptions.UserName & "!")
Resume Next
handleXLSLock:MessageBox.Show("No XLS Saved", "Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Resume Next
'end of iLogic code-----------------------------------------------------------------------------
as you can see in the last rule I sort the parts list on property "TYPE".
this is a custom text property which can be: A, B, C or D.
the thing is that I like to split these. A on sheet1, B on sheet2 etc.