I'm trying to use tool bar buttons (python addins) to add a filepath and then append another feature class (known to have identical schema, no test needed) to that filepath. My syntax isn't working for some reason.
import arcpy, os
from arcpy import env
import pythonaddins
import re
sdeconn1 = r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\Connection to ffxsde.sde"
class WORKSPACEPATH(object):
"""Implementation for addin_addin.WORKSPACEPATH (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
layer_files = pythonaddins.OpenDialog('Select Layers', True, r'C:\GISData', 'Add')
mxd = arcpy.mapping.MapDocument('current')
df = pythonaddins.GetSelectedTOCLayerOrDataFrame()
list22 = []
if not isinstance(df, arcpy.mapping.Layer):
for layer_file in layer_files:
layer = arcpy.mapping.Layer(layer_file)
list22.append(layer_file)
pythonaddins.MessageBox(str(list22), 'INFO', 0)
else:
pythonaddins.MessageBox('Select a data frame', 'INFO', 0)
class APPEND(object):
"""Implementation for addin_addin.APPEND (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
arcpy.Append_management(r"J:\STW\Divisions_&_Branches\MSMD\Branches_&_Sections\GIS\users\Anault\intersections_software_development\OUTPUT.gdb\STW_ST_SIGNS", list22, "NO_TEST","","")
-
2Have you tried opening the Python window of ArcMap to look for any error message thrown when you click the button?PolyGeo– PolyGeo ♦2016年03月10日 22:41:06 +00:00Commented Mar 10, 2016 at 22:41
1 Answer 1
To try and debug this I think you should open the Python window of ArcMap, and look for any error messages thrown when you click the button.
This is described in the Debugging Python add-ins page of the help:
When an add-in fails to work, it is commonly due to a coding or syntax error in the Python script. To discover what exception is being raised, open the Python window in ArcGIS. The exception is automatically printed to the Python window, providing the exact location and cause of the error
and it is the first, and usually only, step I need to debug my Python AddIn buttons.