How to add parts list row to object collection inventor vba
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I am working on a coding project that requires me to add the following to a list (Part Number, Description, Category, G_L, Component Type, Revision Number). Rather then adding them each into their separate lists, I was thinking that adding the entire row from the parts list onto an object collection would be much faster. That way if I need info I can just call from the collection rather then each individual list. it would be much easier and faster. But I am having trouble on adding an entire row to a collection. Any ideas? here is what I have to far.
Public Sub CheckRevised()
Dim ThisDrwing As Inventor.DrawingDocument
Dim oSheet As Sheet
Dim oDrawingView As DrawingView
Dim oModelDoc As Document
Dim ThisAssem As Inventor.AssemblyDocument
Dim oBom As BOM
Dim oBOMView As BOMView
Dim compDef As ComponentDefinition
Dim doc As Document
Dim row As BOMRow
Dim prop As Property
Dim PartNumList As Variant
Dim DescripList As Variant
Dim CategList As Variant
Dim glList As Variant
Dim CompTypeList As Variant
Dim ObjColl As ObjectCollection
'Check if they wanted to run function
IntMsg = MsgBox("This Function initiates a drawing check, would you like to continue?", vbYesNo)
If IntMsg = 6 Then
'Check if drawing
If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then
Set ThisDrwing = ThisApplication.ActiveDocument
'If first sheet not active then prompt that we will default to use the first sheet "Ok?"
If ThisDrwing.ActiveSheet.Name <> ThisDrwing.Sheets(1).Name Then
IntMsgs = MsgBox("First sheet not found active, will default to use first sheet. Ok?", vbYesNo)
End If
If IntMsgs = 7 Then
MsgBox ("Function canceled.")
End
End If
'On sheet look at first views scource, and get scource model
Set oSheet = ThisDrwing.ActiveSheet
Set oDrawingView = oSheet.DrawingViews.Item(1)
Set oModelDoc = oDrawingView.ReferencedDocumentDescriptor.ReferencedDocument
Set ThisAssem = ThisApplication.Documents.Open(oModelDoc.FullDocumentName, True)
Set ThisAssem = ThisApplication.ActiveDocument
Set oBom = ThisAssem.ComponentDefinition.BOM
oBom.StructuredViewEnabled = False
oBom.StructuredViewFirstLevelOnly = False
oBom.PartsOnlyViewEnabled = True
Set oBOMView = oBom.BOMViews(2)
'load parts list into array (Part Number, Description, Category, G_L, Component Type, Revision Number)
ReDim PartNumList(1)
For Each row In oBOMView.BOMRows
Set compDef = row.ComponentDefinitions(1)
Set doc = compDef.Document
ObjColl.Add (doc.PropertySets("Design Tracking Properties")) << HERE IS THE TROUBLE
Next
Else
MsgBox ("File opened must me drawing document, function canceled.")
End
End If
Else
MsgBox ("Function canceled.")
End
End If
End Sub