Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have been developing a few python addins and I'm just wondering what is the best way to re-compile the addin anytime I edit the script.

Currently, if I make an edit to the script, it seems like I have to

  1. Close ArcMap
  2. Go to My addin folder and double click the 'makeaddin' python file
  3. Double click the 'Python Addin File
  4. Restart ArcMap for the changes to come into effect

If I don't do these steps, then the edits aren't recognized. This gets pretty annoying and time consuming when I want to place maybe a simple print line somewhere or I do a small edit just to test a result.

Is there a better way of doing this?

share|improve this question

2 Answers

up vote 6 down vote accepted

You can use the builtin reload function in python to automatically reload your module. What you can do is something like this:

import mymodule

def hook():
    reload(mymodule)
    mymodule.myfunction()

where hook() is what's called by ArcMap and mymodule is the module you're editing between invocations. You may have to edit sys.path to include the path of the module you're editing so that import mymodule does not fail. Or include the directory in site-packages (maybe using python setup.py develop).

share|improve this answer
1  
Of course this would only be helpful during development; I believe the ArcGIS designers intend for you to test your script before building the addin (resources.arcgis.com/en/help/main/10.1/index.html#/…) – cwa Feb 20 at 23:47
This is what I do as well. I also use winpdb for embedded debugging. – blah238 Feb 21 at 0:42
Thanks for the suggestion. This is a little beyond my skill set. Is it difficult to implement? Is there any further information about this that I can use to learn? – Mike Feb 21 at 16:19
1  
I'm a python developer with limited ArcGIS experience, but I'm learning it. I'll update with more details after I figure them out. – cwa Feb 21 at 18:49

I received an answer on the ArcGIS website. Apparently this is the only way to re-compile python addins. Someone has logged an idea on ArcGIS Ideas and I've voted up and commented as well.

Thread is located here:

http://forums.arcgis.com/threads/78034-ArcGIS-Python-Addins-Am-I-doing-this-right

share|improve this answer
1  
Could you add the relevant links to your answer? – blah238 Feb 22 at 20:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.