09-23-2022
12:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-23-2022
12:38 PM
Exception occurs in button class (please don't laugh loud on my debug MsgBox-es):
Imports Inventor
Public Class MyButton
Private _inventor As Application
Private _settingsButton As ButtonDefinition
Public Sub New(inventor As Application)
MsgBox("00")
_inventor = inventor
MsgBox("10")
SetupButtonDefinition()
MsgBox("20")
AddButtonDefinitionToRibbon()
MsgBox("30")
End Sub
Private Sub SetupButtonDefinition()
MsgBox("11")
Dim conDefs As ControlDefinitions = _inventor.CommandManager.ControlDefinitions
_settingsButton = conDefs.AddButtonDefinition(
"CJS Cutter",
"CJSC_VB",
CommandTypesEnum.kEditMaskCmdType,
Guid.NewGuid().ToString(),
"Automatic creation of halved-style paired slots for overlapping perpendicular flat bodies of Multi-Body Part.",
"Cross-Joint Slot Cutter (VB)")
MsgBox("12")
AddHandler _settingsButton.OnExecute, AddressOf MyButton_OnExecute
MsgBox("13")
_settingsButton.StandardIcon = PictureDispConverter.ToIPictureDisp(My.Resources.CJSC_icon_16)
MsgBox("14")
_settingsButton.LargeIcon = PictureDispConverter.ToIPictureDisp(My.Resources.CJSC_icon_32)
MsgBox("15")
End Sub
Private Sub AddButtonDefinitionToRibbon()
MsgBox("21")
Dim ribbon As Ribbon = _inventor.UserInterfaceManager.Ribbons.Item("Part")
MsgBox("22")
Dim ribbonTab As RibbonTab = ribbon.RibbonTabs.Item("id_TabModel")
MsgBox("23")
Dim ribbonPanel As RibbonPanel = ribbonTab.RibbonPanels.Item("Part.id_TabModel.UserCommands")
MsgBox("24")
ribbonPanel.CommandControls.AddButton(_settingsButton)
MsgBox("25")
End Sub
Private Sub MyButton_OnExecute(Context As NameValueMap)
Try
Dim rule As New ThisRule()
rule.ThisApplication = _inventor
rule.Main()
Catch ex As Exception
MsgBox("Something went wrong while running rule. Message: " & ex.Message)
End Try
End Sub
End Class
... but it seems there are two different cases:
Case #1 (SOLVED). If the Add-In is loading with "Load Automatically" option then exception occurs on:
ribbonPanel.CommandControls.AddButton(_settingsButton)
Case #2. If Add-In is loading manually from Add-In Manager then exception occurs on:
_settingsButton = conDefs.AddButtonDefinition( ...
... and it seems not related to my values (reproducible on the code from the article)
Please vote for Inventor-Idea Text Search within Option Names