This is the python file with the code within it. Again, it is a direct copy from the working script that we use daily, so I don't think it is a syntax error, unless there is some functionality that needs to change between stand-alone scripts and add-ins.
import arcpy
import pythonaddins
import os
import arcpy.mapping as map
from arcpy import env
mxd = map.MapDocument("CURRENT")
class map_to_kml(object):
"""Implementation for map_to_kml.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
# Apply Symbology Layer file
# Set local variables
inputLayer = r'Entire Coverage Area\Fiber Segments'
symbologyLayer = r'\\extenet.local\dfs\Network-Planning-GIS\1)Documentation\ArcGIS_Files\4)Symbology_Layer_Files\Fiber Segments (KMZ).lyr'
# Execute the ApplySymbologyFromLayer tool
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer)
# Save the map
mxd.save()
# Map to KML tool
# Set local variables
df = arcpy.mapping.ListDataFrames(mxd)[0].name
mapName = str(mxd.filePath).split('\\')[-1:][0][:-4]
filepath1 = str(mxd.filePath)[:79] + mapName + "/6)Deliverables/"
version = arcpy.GetParameterAsText(0)
outputKML = filepath1 + mapName + " " + version + '.kmz'
extent = 'Same as layer Fiber Segments'
# Execute MapToKML tool
arcpy.MapToKML_conversion(mxd.filePath, df, outputKML, '', '', '', extent,'', '', '')
# Apply Symbology Layer file
# Set local variables
inputLayer = r'Entire Coverage Area\Fiber Segments'
symbologyLayer = r'\\extenet.local\dfs\Network-Planning-GIS\1)Documentation\ArcGIS_Files\4)Symbology_Layer_Files\Fiber Segments.lyr'
# Execute ApplySymbologyFromLayer tool
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer)
Here is the python file just referencing the existing script:
import arcpy
import pythonaddins
import os
relPath = os.path.dirname(__file__)
class map_to_kml(object):
"""Implementation for map_to_kml.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
toolPath = relPath + r'\ExteNet Systems Toolset.tbx'
pythonaddins.GPToolDialog(toolPath, 'Map to KML1')
I made sure that the referenced tool is using relative path names, and the toolbox is in the install folder for the add-in. I tried this with just about every variation of the tool name I could think of. I used the no space version, I used the ".py" afterwards. I also tried the os.startfile() method with a direct link to the tool instead of concatenated as shown above.