Hi @chendersonCRKPU . You can't get visibility information in a Document object, you need to use oRow.ComponentOccurrences.Item(1). Example code:
Private Sub Main()
Dim oDoc As Document = ThisApplication.ActiveDocument
If TypeOf oDoc Is AssemblyDocument Then
Dim oAssDoc As AssemblyDocument = oDoc
If CheckDocMiss(oAssDoc) Then Exit Sub
Call WorkWithAssembly(oAssDoc)
Else If TypeOf oDoc Is DrawingDocument Then
Dim oDrawDoc As DrawingDocument = oDoc
Dim oAssDoc As AssemblyDocument = oDrawDoc.ReferencedDocuments.Item(1)
If CheckDocMiss(oAssDoc) Then Exit Sub
Call WorkWithAssembly(oAssDoc)
Else
MessageBox.Show("This rule can only be run in an assembly or a drawing files.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
Private Sub WorkWithAssembly(ByVal oDoc As AssemblyDocument)
Dim oDef As AssemblyComponentDefinition = oDoc.ComponentDefinition
Dim oBOM As BOM = oDef.BOM
Dim oBOMViewStruc As BOMView = GetBOMstructure(oBOM)
If IsNothing(oBOMViewStruc) Then Exit Sub
For Each oRow As BOMRow In oBOMViewStruc.BOMRows
Dim oOcc As ComponentOccurrence = oRow.ComponentOccurrences.Item(1)
MessageBox.Show("Visible - " & oOcc.Visible, oOcc.Name)
Next
End Sub
Private Function GetBOMstructure(ByVal oBOM As BOM) As BOMView
Dim sLanguageBOM, sSortItem As String
Select Case ThisApplication.LanguageCode
Case "en-US"
sLanguageBOM = "Structured"
sSortItem = "Item"
Case "ru-RU"
sLanguageBOM = "Структурированный"
sSortItem = "Номер"
Case Else
Exit Function
End Select
If oBOM.StructuredViewEnabled = False Then oBOM.StructuredViewEnabled = True
If oBOM.StructuredViewFirstLevelOnly = False Then oBOM.StructuredViewFirstLevelOnly = True
oBOM.BOMViews.Item(sLanguageBOM).Sort(sSortItem, True)
Return oBOM.BOMViews.Item(sLanguageBOM)
End Function
Private Function CheckDocMiss(ByVal oDoc As Document) As Boolean
For Each oRefDoc As DocumentDescriptor In oDoc.ReferencedDocumentDescriptors
If Not oRefDoc.ReferenceSuppressed Then
If oRefDoc.ReferenceMissing Then
Return True
End If
End If
Next
Return False
End Function