Command Manager issue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I seem to be having an issue with using the Command Manager. Whenever the commandmanager is executed, inventor crashes. When i place a dummy MsgBox("Test") directly above the commandmanager, it pops up so, i know that everything is working up to that point
. Even when i place a MsgBox(SymbolName), i get the correct symbol name displayed.
whats even more strange is if i delete the code and pasted the exact same code back, it works for a bit then crashes. It worked last night just fine and today, it doesn't work....
Any ideas? Here is my code.
Public Sub InsertSymbol(SymbolName As String) Dim oDrawDoc As DrawingDocument Set oDrawDoc = ThisApplication.ActiveDocument On Error GoTo NodeError Set oSheet = oDrawDoc.ActiveSheet oSheet.Activate ThisApplication.ActiveView.Fit Dim S As String S = SymbolName ' Get the sketched symbol named "?". Dim oNode As BrowserNode Set oNode = GetSymbolNode(oDrawDoc.BrowserPanes.ActivePane.TopNode, S) ' Select the symbol. Dim oSelectSet As SelectSet Set oSelectSet = oDrawDoc.SelectSet oSelectSet.Clear oNode.DoSelect DoEvents ' Execute the Insert Drawing Sketch Symbol command. ThisApplication.CommandManager.ControlDefinitions.Item("DrawingSketchSymbolInsertCtxCmd").Execute Exit Sub NodeError: MsgBox ("There is an issue with the current Sketch Symbol. It either no longer exists or it has been renamed." & _ vbCrLf & vbCrLf & _ "Please check and try again"), vbOKOnly, "Browser Issue" End Sub Private Function GetSymbolNode(ByVal TopNode As BrowserNode, ByVal SymbolName As String) As BrowserNode ' Iterate through the children of the input node. Dim oNode As BrowserNode For Each oNode In TopNode.BrowserNodes ' Look for the "Sketched Symbols node". If oNode.BrowserNodeDefinition.Label = "Sketched Symbols" Then ' Find the specified node. Dim oSymbolNode As BrowserNode For Each oSymbolNode In oNode.BrowserNodes If UCase(oSymbolNode.BrowserNodeDefinition.Label) = UCase(SymbolName) Then ' Assign the node as the output value and exit the function. Set GetSymbolNode = oSymbolNode Exit Function End If Next End If ' Check if the node has been found and exit the function. If Not GetSymbolNode Is Nothing Then Exit Function Else ' Recursively call this function to traverse the browser tree. Set GetSymbolNode = GetSymbolNode(oNode, SymbolName) End If Next End Function
Nacho
Automation & Design Engineer
Inventor automation Programmer (C#, VB.Net / iLogic)
Furniture, Sheet Metal, Structural, Metal fab, Tradeshow, Fabrication, CNC
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.