Execute addin code after opening project in ArcPro 2.7

884
5
Jump to solution
02-09-2021 03:55 PM
PrashantKirpan
Occasional Contributor

Hi,

I want to execute my addin code after opening project in arcpro. I've config file which stores project related data. Now whenever I open project I need to activate addin and execute code to retrieve config file, to avoid this behavior I would like to execute some code by default on opening project. 

Any help would be appreciated,

-Prashant

 

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JamesBrander
Esri Contributor

Hi @PrashantKirpan ,

It sounds like once our addin is installed, we just want it to execute code in response to the ProjectOpened event. You can find an example of subscribing to this event to execute code when a project is opened in the BackStage_PropertyPage community sample. 

Hope that helps! 

 

View solution in original post

5 Replies
JamesBrander
Esri Contributor

Hi @PrashantKirpan ,

It sounds like once our addin is installed, we just want it to execute code in response to the ProjectOpened event. You can find an example of subscribing to this event to execute code when a project is opened in the BackStage_PropertyPage community sample. 

Hope that helps! 

 

PrashantKirpan
Occasional Contributor

Thank you JamesBrander, perfectly working for me.

-Prashant

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

It seems that you got your add-in to work, but I just wanted to point out that by default add-ins are 'Just-in-time' (JIT) loaded, meaning they are not loaded and running until you interact through the UI with your add-in.  If you want your add-in to work from startup (i.e. in order to listen to a project open/close event) you have to change the JIT default behavior by turning the 'autoload' (in config.daml) to true.  You can find more documentation here:  ProConcepts Framework · Esri/arcgis-pro-sdk Wiki (github.com)

JamalWest2
Occasional Contributor

If I have a proWindow in my add-in how can I cause that prowindow to initialize when the add-in is loaded? right now it only happens ona click of the button.

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

Usually you would not initialize a ProWindow before the class is instantiated, which happens when the ProWindow  needs to open.  I would recommend to move any initialization code into the Module class and make it accessible through an internal (or public) property in the Module class as in this example:  Framework - ProWindowMVVM Community Sample

 

0 Kudos