Pythonaddins script edit

674
5
01-25-2013 12:09 AM
IbraheemKhan1
New Contributor III
I have created an AddIn using pythonaddins. But when I edit python script for that addin and re-create '.esriaddin' file, I don't get updated results using that. Do I need to re-create AddIn each time when I edit python script to cater changes?
Tags (2)
0 Kudos
5 Replies
markdenil
Occasional Contributor III
You DO have to restart ArcMap each time after you update the Add-In.
Once the Add-In is added-in, it remains in memory and does not reread the source script.
It is a bit of a pain (and occasionally frustrating) when debugging...
0 Kudos
IbraheemKhan1
New Contributor III
Thanks for pointing that out. I tried restarting ArcMap but sometimes it still gives old results even if i have updated script and re-created AddIn. Any suggestions?
0 Kudos
MelanieMaguire
New Contributor III
When I save my updated script that is part of an add-in, the add-in tools automatically save a backup for me with a number after it.  Are the updates you have made in the version of your script that the add-in is using, or are the updates in one of the backups?  For one of my add-ins, I realized my updates were not in the current version the add-in was utilizing.  I haven't had time to play around with it to fully understand what is going on yet, but you might want to compare the code in your backup script and the "current" version.
0 Kudos
JohnDye
Occasional Contributor III
When I save my updated script that is part of an add-in, the add-in tools automatically save a backup for me with a number after it.  Are the updates you have made in the version of your script that the add-in is using, or are the updates in one of the backups?  For one of my add-ins, I realized my updates were not in the current version the add-in was utilizing.  I haven't had time to play around with it to fully understand what is going on yet, but you might want to compare the code in your backup script and the "current" version.


The "backup with a number after it" only occurs when you update something through the Pyton Addin Wizard. So if you open the Addin Wizard, and change a Class Name or ID, Image or something else, the Python Addin Wizard is overwriting the existing Config.xml and creating a new, empty Python Script in the install folder with all of the empty classes. It's pretty much like starting over. Luckily, the Addin does check for a AddinName.py file in the Install Directory first and if it finds one, renames it appending a number to the end.

If you just want to update logic without getting the backup script generated, you should just open the script in your IDE directly, edit the logic and save over the existing script. If you want to update a class name or ID or graphic or other item that you originally specified in the Python Addin Wizard, but dont want to generate a new empty script with all of your classes, you should just alter the Config.XML .

I would backup the existing Config.xml somewhere else first before I did that. Also, remember that if you update a Class or ID in the Config.xml, you have to update it in the script as well so that the Config.xml can call the Class in the Script. The easiest way to do this with PyScripter is to just open the Config.xml and .Py files, perform a Find/Replace on the XML, then change the tab to the .PY file and run the same Find/Replace again, then save everything.
0 Kudos
MelanieMaguire
New Contributor III
Thanks! That is useful to know.
0 Kudos