Detect Component Pattern as selection or in SelectSet
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a (too long) iLogic rule that does several things.
One of these: The browser pane is collapsed and when a part or assembly is selected the 'find in browser' function is called for what is selected and this browser node(s) is/are expanded so that you have a direct view on the constraints.
This works fine until...
A part or assembly is part of a component pattern.
I would like to know how to detect that a component pattern is selected.
I would rather know which part or assembly is selected in the component pattern.
Is it possible to find out?
Below is the piece of code where we end up when the iLogic rule is activated and a selection has been made.
Here you can see that with 'GetBrowserNodeFromObject' the browser node can be found.
As already mentioned, is it also possible to determine when the selection is a component pattern?
And even better, can also be determined what is selected in the component pattern?
' -------------------------------------------------------------------------------------------------------------------------------------------------------------
' When there was a selection made, highlight the selection and expand the node(s) to see the Constraints
If ThisApplication.ActiveDocument.SelectSet.count <> 0 Then ' Something is selected
' Show number of selected items in StatusBar
ThisApplication.StatusBarText = "Selected items: " & ThisApplication.ActiveDocument.SelectSet.count
'MessageBox.Show("Wait")
Try
'MessageBox.Show(ThisApplication.ActiveDocument.SelectSet.count)
'For i = 1 To ThisApplication.ActiveDocument.SelectSet.count
For i = ThisApplication.ActiveDocument.SelectSet.count To 1 Step -1 ' In Reverse order
oOcc = ThisApplication.ActiveDocument.SelectSet(i)
' Get the model browser
Dim oPane As BrowserPane
oPane = oAssemDoc.BrowserPanes.ActivePane
' Get the browser node that corresponds to the occurrence
Dim oCompo As BrowserNode
oCompo = oPane.GetBrowserNodeFromObject(oOcc)
'oCompo.Expanded = True
'oCompo.DoSelect
Dim oNode As BrowserNode
For Each oNode In oCompo.BrowserNodes
'MessageBox.Show(oNode.FullPath)
If oNode.FullPath.Contains("Origin") Then 'Or oNode.FullPath.Contains("Position") Then
oNode.Expanded = False
Try
If oNode.FullPath.Contains("Position") Then oNode.Expanded = False
Catch
End Try
Else If oNode.FullPath.Contains("Folded Model") Or oNode.FullPath.Contains("Representations") Then
Dim oNodeSheet As BrowserNodeDefinition
oNodeSheet = oNode.BrowserNodeDefinition
' Get the work plane browser node.
Dim oWorkPlaneNode As BrowserNode
oWorkPlaneNode = oCompo.AllReferencedNodes(oNodeSheet).Item(1)
Dim oNode2 As BrowserNode
For Each oNode2 In oWorkPlaneNode.BrowserNodes
Try
If oNode2.FullPath.Contains("Origin") Then
oNode2.Expanded = False
End If
Catch
End Try
Try
If oNode2.FullPath.Contains("Position") Then
oNode2.Expanded = False
End If
Catch
End Try
Try
If oNode2.FullPath.Contains("Folded Model") Then
oNode.Expanded = False 'oNode! NO oNode2!
End If
Catch
End Try
Try
If oNode2.FullPath.Contains("Representations") Then
oNode.Expanded = False 'oNode! NO oNode2!
End If
Catch
End Try
''' Try
''' If oNode2.FullPath.Contains("Model States") Then
''' If oNode2.Visible = True Then oNode.Expanded = False 'oCompo.Expanded = False
''' End If
''' Catch
''' End Try
Next
End If
Next
'MessageBox.Show("Wait")
' Expand the browser node that corresponds to the occurrence
'MessageBox.Show(oCompo.Expanded)
oCompo.Expanded = True
''' Call ThisApplication.UserInterfaceManager.DoEvents
''' If oCompo.Expanded = False Then
''' Call ThisApplication.UserInterfaceManager.DoEvents
''' oCompo.Expanded = True
''' ElseIf oCompo.Expanded = True Then
''' Call ThisApplication.UserInterfaceManager.DoEvents
''' oCompo.Expanded = False
''' End If
'Call ThisApplication.UserInterfaceManager.DoEvents
Call ThisApplication.CommandManager.ControlDefinitions.Item("AppFindInBrowserCtxCmd").Execute
Next
Catch
End Try
For completeness, the complete rule as a txt file.
Note that the rule interacts with another iLogic rule and a vba piece of code due to a bug in IV2022.
So I don't think it can be tested directly.