Description
When using the Add-InventorMenuItem cmdlet to add a button to the Inventor coolOrange ribbon and customized Datastandard for Inventor at the same time the ribbon doesn't show up and the log file contains the following warning
2023-10-20 15:30:04,819 [10] WARN powerEvents.Cmdlets.Inventor.InventorUserInterfaceUserInterface - InventorUserInterfaceUserInterface.AddButton("test", {powerEvents.Cmdlets.Inventor.RegisteredInventorMenuItemCommand}) | Failed, exception = {System.Runtime.InteropServices.COMException}.
System.Runtime.InteropServices.COMException (0x8000FFFF): Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Inventor.ControlDefinitions.AddButtonDefinition(String DisplayName, String InternalName, CommandTypesEnum Classification, Object ClientId, String DescriptionText, String ToolTipText, Object StandardIcon, Object LargeIcon, ButtonDisplayEnum ButtonDisplay)
at ?.?..ctor(String displayName, String internalName, ControlDefinitions inventorControlDefinitions, Action onExecute)
at powerEvents.Cmdlets.Inventor.InventorUserInterfaceUserInterface.AddButton(String name, IRegisteredInventorCommand command)
Cause
This happens if any coolorange cmdlets are imported in the Datastandard scripts on the script level. For example
Import-Module powerVault
Solution
Instead of importing the module directly in the script call the Import-Module cmdlet in one of your functions. A good place to do this would be the InitializeWindow function