Hi, I have a problem with running a Python-Add-In twice in one ArcMap-Project. During the first use of the Add-In a join between a Shape-File and another DBase-File is created. Using the Add-In a second time the join does not gets actualized.
in __init__ or onClick set arcpy.env.overwriteOutput = True
And in future, please post your code as a formatted code block, not as a screenshot. https://community.esri.com/people/curtvprice/blog/2014/09/25/posting-code-blocks-in-the-new-geonet
Do you remove the join between runs of the addin?
No, I tried but I did not manage.
Can you help me how to remove the join in the Add-In?
Excuse my english, I do not have much practice.
Christian, no problem... the scripting example can be found in the Remove Join tool documentation. The only reason I was questioning this, is perhaps the tool won't allow for another join if the file already has a join on it. I am not sure whether you want the join to be removed once it is completed or whether you want to join the file and then produce a new one with the joined data, in which case you could use a copy features tool/script example to keep the resultant files together into a new file.
What I want to do is to actualize the Shape-File when the content of the joined dbf-file has changed.
Then once the join is made, you will have to implement the code example in the Copy features tool to save the combined result to a new shapefile. I would also recommend that you then remove the join using the code from the remove join tool to remove the join, in case you wish to join another file to the original shapefile and repeat the process.
When running your add in, have the ArcMap python window open (Geoprocessing - Python menu) so you can see any error messages.
This is the error message (German):
Dataset allready exist
Failed to execute "MakeFeatureLayer"
But if I remove the layer on this way:
and start the join twice the python-window shows the same error message.
Dear Dan, dear Luke,
thank you very much for your help.
Now my Add-In works as it should.
Using "arcpy.Delete_Management" on the layer worked and setting "arcpy.env.overwriteOutput = True" gave the same positive result.
Thanks so much from Göttingen in Germany.
Retrieving data ...