Problem with running a Python-Add-In twice

3128
9
Jump to solution
04-27-2015 02:23 AM
ChristianVorstadt
New Contributor

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.

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

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

View solution in original post

0 Kudos
9 Replies
DanPatterson_Retired
MVP Emeritus

Do you remove the join between runs of the addin?

0 Kudos
ChristianVorstadt
New Contributor

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.

0 Kudos
DanPatterson_Retired
MVP Emeritus

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.

0 Kudos
ChristianVorstadt
New Contributor

What I want to do is to actualize the Shape-File when the content of the joined dbf-file has changed.

0 Kudos
DanPatterson_Retired
MVP Emeritus

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.

Luke_Pinner
MVP Regular Contributor

When running your add in,  have the ArcMap python window open (Geoprocessing -  Python menu) so you can see any error messages.

0 Kudos
ChristianVorstadt
New Contributor

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.

0 Kudos
Luke_Pinner
MVP Regular Contributor

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

0 Kudos
ChristianVorstadt
New Contributor

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.

Christian Vorstadt

0 Kudos