- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Firstly I am new to this forum and to i-logic, so my code may be sloppy or unnecessary (please bear with it). We are working on a file clean-up activity in our organization. It requires us to check large assemblies, part-by-part for incorrect i-properties, unconstrained sketches, wrong file locations, etc. We have been working on this by exporting the top-level assembly's Structured BOM (with 'All levels' and a delimiter, so that it is easy to understand and work with the exported BOM).
The problem is that many users have (by mistake) set purchased items and sometimes even fabrication items to "Reference" in top assembly and many of its sub-assemblies. The result is that they get dropped out of our exported Excel spreadsheet. The spreadsheet data is used for many other subsequent processes, so we need the BOM to contain all of the data, irrespective of what BOM structure it is.
To get this done easily, I have created an i-logic code that will pull out the part number, title of the reference items into an Input Box, so that I can copy them into an Excel file, use the 'Convert Text to Column Wizard' in Excel to split these two entries and then copy-paste them onto the main BOM spreadsheet.
The process is much quicker than manual entry, but it would be better if the code can just do the entire work - scan through the entire assembly, check each sub-assembly, look for reference items, add them to the part list along with the item no. (with delimiter) and then export the whole structured BOM to an Excel file. Any help will be appreciated!
This is the code I have:
Dim AssyDoc As AssemblyDocument
Dim AssyCompDef As AssemblyComponentDefinition
Dim Occs As ComponentOccurrences
AssyDoc = ThisApplication.ActiveDocument
AssyCompDef = AssyDoc.ComponentDefinition
Occs = AssyCompDef.Occurrences
Dim OccCount As Integer 'Total number of occurrences
Dim RefOccCount As Integer 'Total number of occurences that are set to reference
Dim i As Integer 'Iteration integer for occurrences
Dim j As Integer 'Iteration integer for occurrences that are set to reference
j = 1
RefOccCount = 0
OccCount = Occs.Count
For i = 1 To OccCount
Dim Occ As ComponentOccurrence
Occ = Occs.Item(i)
If Occ.BOMStructure = kReferenceBOMStructure
RefOccCount = RefOccCount + 1
Else
End If
Next
If RefOccCount < 1
MsgBox("No Reference items found !", vbOKCancel,"i-Logic")
Else
Dim RefList(RefOccCount) As String
For i = 1 To OccCount
Dim Occ As ComponentOccurrence
Occ = Occs.Item(i)
If Occ.BOMStructure = kReferenceBOMStructure
Dim OccDocCD As ComponentDefinition
Dim OccDoc As Document
Dim PropSets As PropertySets
Dim PropSet1 As PropertySet
Dim PropSet2 As PropertySet
Dim PNo As [Property]
Dim OccTitle As [Property]
OccDocCD = Occ.Definition
OccDoc = OccDocCD.Document
PropSets = OccDoc.PropertySets
PropSet1 = PropSets.Item("Design Tracking Properties")
PropSet2 = PropSets.Item("Inventor Summary Information")
PNo = PropSet1.Item("Part Number")
OccTitle = PropSet2.Item("Title")
RefList(j) = j & "|" & PNo.Value & "|" & OccTitle.Value
j = j + 1
Else
End If
Next
Dim FinalText As String
FinalText = Join (RefList, vbCrLf)
InputBox("List of Reference Items:", "i-Logic", FinalText)
End If
Solved! Go to Solution.