Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

OnEnvironmentChange event not fired.

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
NemKumar
506 Views, 4 Replies

OnEnvironmentChange event not fired.

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,

4 REPLIES 4
Message 2 of 5
wayne.brill
in reply to: NemKumar

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 3 of 5
NemKumar
in reply to: wayne.brill

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.

Message 4 of 5
wayne.brill
in reply to: NemKumar

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 5 of 5
NemKumar
in reply to: wayne.brill

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report