Hi,
I have created two plugins in which new environment is created. Ribbon panels for both the plugin appears in the environment tab. When it is clicked, new set of buttons appear. Before new set of buttons appear, I have to perform a task which I am doing by handling OnEnvironmentChange event.
It works fine. But when I load the other plugin ( in second plugin also, I am doing certain tasks on OnEnvironmentChange), the OnEnvironmentChange event for the first plugin doesnt fire. The second one works fine.
It seems as if as soon as second one is enabled, the first one stops firing OnEnvironmentChange event. Its a bit strange but does OnEnvironmentChange event allow only one eventHandler (the last one attached.)
How can I get the OnEnvironmentChange event for both the apps. Also, can I get the button click event for the plugin buttons in environment tab.
I get button click event for the buttons opened in new environment AdditionalVisibleTabs, not on the main button.
Need Urgent help,
Thanks & Regards,
Solved! Go to Solution.
Solved by wayne.brill. Go to Solution.
Hi,
In my tests I am able to recreate the behavior you describe if I set the HandlingCode that is passed into the event to kEventHandled. HandlingCode = HandlingCodeEnum.kEventHandled Can you check this?
Here is an excerpt from the help file:
>> >>
HandlingCodeEnum Enumerator
kEventCanceled 515 Canceled: Return this code if you want Inventor's native 'cancel' or 'fail' behavior.
kEventHandled 513 Handled: Return this code if Inventor should now bypass its native behavior.
kEventNotHandled 514 Not Handled: Return this code if Inventor should carry on with its native behavior.
<< <<
If this does not help please provide a couple of examples that will allow me to recreate the behavior you are seeing. Also I am not sure what you mean with this statement:"can I get the button click event for the plugin buttons in environment tab" Please provide some screenshots or if possible a project that will allow me to research this problem.
Thanks,
Wayne
I am not able to set the EventHandled for my apps which will allow me to generate OnEnvironmentChange.
Therefore, I am attaching two plugin projects, OnEnvironmentChange is not fired for both apps.
Please have a look at the code and let me know where to change.
Hi,
Thanks for providing the project. I changed the code to kEventNotHandled and I am getting the event in both Add-Ins. Please explain what is wrong when you set Handling code to this value. Here is a code snippet that shows what I did. (Made this change to both Add-Ins) I use the MessageBox to see the event handler getting called.
void FinishApplicationTWO(Inventor.Environment environment, EnvironmentStateEnum EnvironmentState, EventTimingEnum BeforeOrAfter, NameValueMap Context, out HandlingCodeEnum HandlingCode)
{
//WB added
System.Windows.Forms.
MessageBox.Show("From APP 2");
//WB end added
//Finish Button is clicked
try
{
if (BeforeOrAfter == EventTimingEnum.kAfter)
if (environment.InternalName == "ApplicatioTWO")
{
if (EnvironmentState == EnvironmentStateEnum.kTerminateEnvironmentState)
{
//Adding my ribbon enable/disable code
}
}
//WB commented
// HandlingCode = HandlingCodeEnum.kEventHandled;
//WB Added
HandlingCode =
HandlingCodeEnum.kEventNotHandled;
}
Thanks,
Wayne
Thanks, its works actually. thats great. We had tried with HandlingCodeEnum.kEventNotHandled, but it did not work, perhaps we did not change in all the projects.