- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So, we are using two types of Pats List for drawings: a Parts List, and an Equipment List.
The parts list is for manufactured assemblies which require all parts to be named, an equipment list is for general arrangement drawings where you just want to highlight a few systems.
The most important difference is that an Equipment List will only show Ballooned items.
Now I tried to write some iLogic that will recognise which Parts List is placed first (so that it always works, even when using multiple Parts Lists for whatever reason) and will renumber the BOM based on this.
- In case of a Parts List, it is determined simply be Title.
- But when using an Equipment List, it has to first number the items placed on the Equipment List, and then number the rest of the items based on Title.
Now I got it mostly working, by renumbering all parts to "X" and then numbering them according to above set rules. The only problem is I'm having is when I have an Equipment List that every second attempt to run the code will result in all numbers remaining as "X". Running it again will work fine.
I think this is because I first try to Renumber the Equipment list, and then SaveItemsOverrideToBOM. However, this can get an error when the BOM and Equipment List correspond. I tried to fix this by placing this part of the code in a Try/Catch instance, but it might still break because of the order?
Anyone able to find out what is going wrong here?
Dim oDrawDoc As DrawingDocument
oDrawDoc = ThisApplication.ActiveDocument
Dim oCurrentDoc As AssemblyDocument
oCurrentDoc = ThisDrawing.ModelDocument
Dim oBOM As BOM
oBOM = oCurrentDoc.ComponentDefinition.BOM
oBOMView = oBOM.BOMViews(2)
Dim oListCheck = 0 'Variable that will keep track of how many parts lists there are
For Each oPartslist As Inventor.PartsList In oDrawDoc.ActiveSheet.PartsLists
oListCheck = oListCheck + 1 'Another Parts List
If oListCheck = 1 'Only the first PartsList should renumber the BOM
If oPartslist.Title = "Equipment List" Then
Try
oPLR = oPartslist.PartsListRows.Count 'See how many items are added to the Equipment List
oBOMCounter = oPLR + 1 'All items not in Equipment List should start at length + 1
For Each oBR In oBOMView.BOMRows 'Renumber BOM to start clean
oBR.ItemNumber = "X"
Next oBR
oPartslist.Sort("DESCRIPTION") 'Sort Equipment List, renumber and write new numbers to 'clean' BOM
oPartslist.Renumber
oPartslist.SaveItemOverridesToBOM
oBOMView.Sort("Item", ,"Description") 'Sort BOM so that all items not numbered are sorted by description
For Each oBR In oBOMView.BOMRows 'Rename all items not in Equipment List
If oBR.ItemNumber = "X"
oBR.ItemNumber = oBOMCounter
oBOMCounter = oBOMCounter + 1
End If
Next
Catch
End Try
Else If oPartslist.Title = "Parts List" 'When using a Parts List, simply renumber BOM based on Title
oBOMView.Sort("Description")
oBOMView.Renumber(1,1)
oPartslist.Sort("ITEM") 'Sort Parts list by newly numbered BOM
End If
Else
If oPartslist.Title = "Equipment List" Then 'Sort functions for not-primary parts lists
oPartslist.Sort("DESCRIPTION")
Else If oPartslist.Title = "Parts List"
oPartslist.Sort("ITEM")
End If
End If
Next
Solved! Go to Solution.