Hi @amarcoc. In order to effectively use that 'find in browser' command, you need to have a single model entity selected (a single valid object within the Document.SelectSet), before executing that command. So, just as @Curtis_Waguespack stated, since we are doing that same action by API code, executing that command is not necessary anymore, so you can get rid of that command from the end of your code, because it is not accomplishing anything.
Also, here is just another example of an iLogic rule to expand the 'Origin' node, when the selected component may or may not be a sheet metal part. I chose to create handy little custom Function just for finding a BrowserNode by its 'Label' under a given BrowserNode, even if it may be multiple levels under that node. It will simply return the 'first' BrowserNode that it finds matching the specified label under the specified BrowserNode. The main code first tries to find the node for the 'Folded Model'. If found, it will then try to find the 'Origin' node under that. If the 'Folded Model' node was not found, it then just tries to find the 'Origin' node under the main node. Once it has the 'Origin' node, it sets it to expanded. Once it does that, even if the component node was not expanded at all, this will immediately expand all 3 nodes (component node, folded model node, & origin node) at once.
Sub Main
oDoc = ThisDoc.Document
oSS = oDoc.SelectSet
If oSS.Count = 0 Then
MsgBox("A single component must be pre-selected before running this rule.", vbCritical, "")
Exit Sub
End If
Dim oOcc As ComponentOccurrence
If TypeOf oSS.Item(1) Is ComponentOccurrence Then
oOcc = oSS.Item(1)
Else
MsgBox("A single component must be pre-selected before running this rule.", vbCritical, "")
Exit Sub
End If
Dim oPane As BrowserPane = oDoc.BrowserPanes.Item("AmBrowserArrangement") 'using its 'InternalName'
Dim oOccNode As BrowserNode = oPane.GetBrowserNodeFromObject(oOcc)
Dim oFMNode As BrowserNode = GetBrowserNodeByLabel(oOccNode, "Folded Model")
Dim oOriginNode As BrowserNode = Nothing
If IsNothing(oFMNode) Then
oOriginNode = GetBrowserNodeByLabel(oOccNode, "Origin")
Else
oOriginNode = GetBrowserNodeByLabel(oFMNode, "Origin")
End If
If IsNothing(oOriginNode) Then
Exit Sub
Else
oOriginNode.Expanded = True
End If
End Sub
Function GetBrowserNodeByLabel(oStartBNode As BrowserNode, oLabel As String) As BrowserNode
If IsNothing(oStartBNode) Then Return Nothing
'look at this level completely first
For Each oNode As BrowserNode In oStartBNode.BrowserNodes
If oNode.BrowserNodeDefinition.Label = oLabel Then Return oNode
Next
'if nothing returned, now try stepping down into lower levels
For Each oNode As BrowserNode In oStartBNode.BrowserNodes
If oNode.BrowserNodes.Count > 0 Then GetBrowserNodeByLabel(oNode, oLabel)
Next
Return Nothing
End Function
Wesley Crihfield

(Not an Autodesk Employee)