Hello,
I have created several custom command which work in Drawing, Part and Assemblies. And I have use OnEnviromentChange event to enable & disable those. But while doing this Dynamic simulation and Stress Analysis was disable automatically. When I'm removing this event then both are enabled.
Can anyone help me to resolved it?
Solved! Go to Solution.
Solved by jatindevaiya08. Go to Solution.
To disable and enable commands you need to get hold of the "ControlDefinition". This property can "Enables/Disables the UIDefinition objects.". That could work like this:
Dim Ribbon As Ribbon = ThisApplication.UserInterfaceManager.Ribbons.Item("Ribbon name")
Dim ribbonTab As RibbonTab = Ribbon.RibbonTabs.Item("Ribbon tab name")
Dim ribbonPanel As RibbonPanel = ribbonTab.RibbonPanels.Item("Ribbon panel name")
Dim commandControl As CommandControl = ribbonPanel.CommandControls.Item("Command controls name")
commandControl.ControlDefinition.Enabled = False
Jelte de Jong
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.
Blog: hjalte.nl - github.com
@JelteDeJong
I have used UserInterFace as well as UserInput Event. So some of the command is in ribbon and some on ContextMenu.
That's why I have used OnEnvironmentChange Event to disabled it. But facing issue in Assembly Environment only where those two command is disabled.
Instead of OnEnvironmentChange I have used OnActiveDocument event to disable or enable custom command and it's work fine. Dynamic simulation and Stress Analysis is not disabled by this method.
Can't find what you're looking for? Ask the community or share your knowledge.