I'm trying to merge two rules
Set the LOD on each level
Suppress a folder
Both work but i'd like to suppress the folder on each level:
Folder named 'Reference' is supressed:
Sub Main()
Dim oDoc As AssemblyDocument
oDoc = ThisApplication.ActiveDocument
Dim oPane As BrowserPane
oPane = oDoc.BrowserPanes("Model")
Dim oTopNode As BrowserNode
oTopNode = oPane.TopNode
Dim oFolder As BrowserFolder
oFolder = oTopNode.BrowserFolders.Item("Reference")
Call SuppressFolder(oFolder)
End Sub
' Recursive function as there could be subfolders too
Sub SuppressFolder(oFolder As BrowserFolder)
Dim oItem As BrowserNode
For Each oItem In oFolder.BrowserNode.BrowserNodes
Dim oObj As Object
oObj = oItem.NativeObject
If TypeOf oObj Is BrowserFolder Then
Call SuppressFolder(oObj)
ElseIf TypeOf oObj Is ComponentOccurrence Then
Dim oOcc As ComponentOccurrence
oOcc = oObj
If Not oOcc.Suppressed Then Call oOcc.Suppress
ElseIf TypeOf oObj Is OccurrencePattern Then
Dim oPatt As OccurrencePattern
oPatt = oObj
Dim oElem As OccurrencePatternElement
For Each oElem In oPatt.OccurrencePatternElements
For Each oOcc In oElem.Occurrences
If Not oOcc.Suppressed Then Call oOcc.Suppress
Next
Next
End If
Next
End Sub
all levels are set to 'Simple without ref'
Sub Main()
Dim oDoc As Document
oDoc = ThisDoc.Document
Dim oAssyDoc As AssemblyDocument
oAssyDoc = TryCast(oDoc, AssemblyDocument)
If oAssyDoc Is Nothing Then
MessageBox.Show("Document not of Assembly Type")
Exit Sub
End If
Try
oAssyDoc.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Simple without REF").Activate
Catch
MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oAssyDoc.DisplayName)
End Try
Dim oOccs As ComponentOccurrences
oOccs = oAssyDoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject
'MessageBox.Show(oOcc.Name)
iLogicVb.RunRule("Rule3")
Try
oOcc.SetLevelOfDetailRepresentation("Simple without REF")
Catch
MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oOcc.Name)
End Try
End If
Next
End Sub
Merging the two:
No errors but the folder isn't suppressed either.
Sub Main()
Dim oDoc As Document
oDoc = ThisDoc.Document
Dim oAssyDoc As AssemblyDocument
oAssyDoc = TryCast(oDoc, AssemblyDocument)
Dim oPane As BrowserPane
oPane = oDoc.BrowserPanes("Model")
Dim oTopNode As BrowserNode
oTopNode = oPane.TopNode
Dim oFolder As BrowserFolder
oFolder = oTopNode.BrowserFolders.Item("Reference")
If oAssyDoc Is Nothing Then
MessageBox.Show("Document not of Assembly Type")
Exit Sub
End If
Try
oAssyDoc.ComponentDefinition.RepresentationsManager.LevelofDetailRepresentations("Simple without REF").Activate
Catch
MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oAssyDoc.DisplayName)
End Try
Dim oOccs As ComponentOccurrences
oOccs = oAssyDoc.ComponentDefinition.Occurrences
For Each oOcc As ComponentOccurrence In oOccs
If oOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject
'MessageBox.Show(oOcc.Name)
Try
oOcc.SetLevelOfDetailRepresentation("Simple without REF")
Call SuppressFolder(oFolder)
Catch
MessageBox.Show("Unable to find 'Simple without REF' LOD on " & oOcc.Name)
End Try
End If
Next
End Sub
' Recursive function as there could be subfolders too
Sub SuppressFolder(oFolder As BrowserFolder)
'Dim oItem As BrowserNode
'Dim oFolder As BrowserFolder
'oFolder = oTopNode.BrowserFolders.Item("Reference")
For Each oItem In oFolder.BrowserNode.BrowserNodes
Dim oObj As Object
oObj = oItem.NativeObject
If TypeOf oObj Is BrowserFolder Then
Call SuppressFolder(oObj)
ElseIf TypeOf oObj Is ComponentOccurrence Then
Dim oOcc As ComponentOccurrence
oOcc = oObj
If Not oOcc.Suppressed Then Call oOcc.Suppress
ElseIf TypeOf oObj Is OccurrencePattern Then
Dim oPatt As OccurrencePattern
oPatt = oObj
Dim oElem As OccurrencePatternElement
For Each oElem In oPatt.OccurrencePatternElements
For Each oOcc In oElem.Occurrences
If Not oOcc.Suppressed Then Call oOcc.Suppress
Next
Next
End If
MessageBox.Show("76", "Title")
Next
End Sub
i'll keep trying.
Regards
Andrew