Skip to content

Instantly share code, notes, and snippets.

@knu2xs
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knu2xs/8837543 to your computer and use it in GitHub Desktop.
Save knu2xs/8837543 to your computer and use it in GitHub Desktop.
Small modifications to the default file created by the Python Add-In assistant to be able to include and use a custom toolbox and tool as part of an add-in.
import arcpy
import pythonaddins
import os
class addDefinitionQueryLayers(object):
"""Implementation for arcpyMappingAddin_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
# name of toolbox without tbx extension
toolboxName = "Mapping"
# name of tool to be executed
toolName = "AddDefinitionQueryLayers"
# create string with path to toolbox
toolboxPath = os.path.join(os.path.dirname(__file__), toolboxName + ".tbx")
# call geoprocessing tool
pythonaddins.GPToolDialog(toolboxPath, toolName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment