Welds

Welds

Anonymous
Not applicable
297 Views
2 Replies
Message 1 of 3

Welds

Anonymous
Not applicable

I want to make a rule which will make a user pick a weld. I think it is not possible with this line of code:

SyntaxEditor Code Snippet

a1=ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter,"Select a weld")

But it is posiible with mouse events like this:

 

Please only ilogic code........


Sub Main() Dim oInteraction As InteractionEvents oInteraction = ThisApplication.CommandManager.CreateInteractionEvents Dim oMouse As MouseEvents oMouse = oInteraction.MouseEvents AddHandler oMouse.OnMouseDown ,AddressOf oMouse_OnMouseDown oInteraction.Start End Sub Sub oMouse_OnMouseDown(Button As MouseButtonEnum, ShiftKeys As ShiftStateEnum, ModelPosition As Point, ViewPosition As Point2d, view As View) MsgBox (Button) End Sub

 

The rule only needs to make an user pick somthing from the browser node (in this case weld bead)

0 Likes
298 Views
2 Replies
Replies (2)
Message 2 of 3

JamieVJohnson2
Collaborator
Collaborator

One method could be to do a test on the browser tree(BrowserPane) for all nodes (BrowserNode) until you find the one that has .Selected = true.  However, browser has nodes within nodes, and folders with nodes as well, so you need to be careful.

Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes
Message 3 of 3

JamieVJohnson2
Collaborator
Collaborator

I got bored, so here is the code that will find the active node in a browser and return it.

Sub Main
	Dim invDoc As Inventor.Document = ThisApplication.ActiveDocument
	Dim bn As Inventor.BrowserNode = FindActiveModelBrowserNode(invDoc)
	MsgBox(bn.FullPath)
End Sub

Public Function FindActiveNode(bnParent As Inventor.BrowserNode) As Inventor.BrowserNode
    For Each bn As Inventor.BrowserNode In bnParent.BrowserNodes
        If bn.Selected = True Then
            Return bn
        End If
        If bn.BrowserNodes.Count > 0 Then
            Dim bnChild As Inventor.BrowserNode = FindActiveNode(bn)
            If bnChild IsNot Nothing Then
                Return bnChild
            End If
        End If
    Next
    Return Nothing
End Function

Public Function FindActiveModelBrowserNode(invDoc As Inventor.Document) As Inventor.BrowserNode
    For Each bp As BrowserPane In invDoc.BrowserPanes
        If bp.Name = "Model" Then
            Dim bnTop As BrowserNode = bp.TopNode
            Dim bn As Inventor.BrowserNode = FindActiveNode(bnTop)
            Return bn
        End If
    Next
    Return Nothing
End Function
Jamie Johnson : Owner / Sisu Lissom, LLC https://sisulissom.com/
0 Likes