Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
How to disable the button when in the sketch environment (or any other)?
I was looking through the rack face sample and thought I had it but alas, no. In the attachment you can see my button is still enabled when an assembly sketch is active. I intend to replace the Create Component button. FYI i'm a novice when it comes to .NET and addins so spell it out for me.
Alternatively is there a better sample I can look at?
I have already added the handler to the activate event. My button definition is a public variable in another module, could this be the problem?
Public Sub m_UIEvents_OnEnvironmentChange(ByVal environment As Environment, ByVal environmentState As EnvironmentStateEnum, ByVal beforeOrAfter As EventTimingEnum, ByVal context As NameValueMap, ByRef handlingCode As HandlingCodeEnum) Try Dim envInternalName As String = environment.InternalName If Not envInternalName = "AMxAssemblyEnvironment" Then 'Enable the "Rack Face" button when the part environment is activated or resumed If environmentState = EnvironmentStateEnum.kActivateEnvironmentState Or environmentState = EnvironmentStateEnum.kResumeEnvironmentState Then BtnDefCreateInPlace.Enabled = True 'm_rackFaceCmd.ButtonDefinition.Enabled = True End If 'Disable the "Rack Face" button when the part environment is terminated or suspended If environmentState = EnvironmentStateEnum.kTerminateEnvironmentState Or environmentState = EnvironmentStateEnum.kSuspendEnvironmentState Then BtnDefCreateInPlace.Enabled = False 'm_rackFaceCmd.ButtonDefinition.Enabled = False End If End If handlingCode = HandlingCodeEnum.kEventNotHandled Catch End Try End Sub
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.
---------------------------------------------------------------------------------------------------------------------------
Inventor 2010 Certified Professional
Currently using 2023 Pro
Solved! Go to Solution.