- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
FYI I have simplified the below programs as much as possible just to make it easier for you to help me. With the top one, I would have safe guards to make sure they only have one component selected. So to see it work, open an assembly and then select one of the components before running it. The second one you don't select anything.
Is there a way to get the BOMStructureEnum.kReferencedBOMStructure value from a file reference? For example, if I have a component in an assembly selected, I can get what I am after like this:
Sub selected()
Dim odoc As Document
Set odoc = ThisApplication.ActiveDocument
Dim oSS As SelectSet
Set oSS = odoc.SelectSet
'HELP
If oSS.Item(1).BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
MsgBox ("Reference")
Else: MsgBox ("Normal")
End If
'END HELP
End Sub
If you look at the line right after the 'Help, that is what I am wanting to do with file references. So here is what I have so far but I can't get it to work. The line right after the 'Help below throws an error:
Sub FileRefs()
' Get the active assembly.
Dim odoc As Document
Set odoc = ThisApplication.ActiveDocument
Dim oAsmDoc As AssemblyDocument
Set oAsmDoc = ThisApplication.ActiveDocument
' Get all of the referenced documents.
Dim oRefDocs As DocumentsEnumerator
Set oRefDocs = oAsmDoc.AllReferencedDocuments
' Iterate through the list of documents.
Dim oRefDoc As Document
For Each oRefDoc In oRefDocs
MsgBox oRefDoc.DisplayName
Set oPropSet = oRefDoc.PropertySets("{F29F85E0-4FF9-1068-AB91-08002B27B3D9}")
'Dim oProp As Property
Set oProp = oPropSet.Item("Comments")
'MsgBox oProp.Value
If oProp.Value = "" Then GoTo Skip:
'HELP
If oRefDoc.BOMStructure = BOMStructureEnum.kReferenceBOMStructure Then
MsgBox ("Reference")
Else: MsgBox ("Normal")
End If
'End HELP
Skip:
Next
End Sub
Solved! Go to Solution.