AnsweredAssumed Answered

Add-in Button Help - Failed to open tool [toolname] (mytoolbox.tbx)

Question asked by david.round on Oct 25, 2016
Latest reply on Nov 8, 2016 by rastrauch



I'm having trouble adding a button using add-ins for a script tool that I made in ArcMap 10.4. I followed the instructions to the letter but I'm getting the error message "Failed to open tool [toolname] (mytoolbox.tbx). I don't understand why. I guess it's found the toolbox but won't run the tool. The code itself is very simple. It's just a reconstruction of the select by location tool to enable Geodesic selections (which really should be standard!) and the tool runs absolutely fine when I run it from the toolbox. The code to run the addin is a simple GPToolDialog call.


Here's the code for the add-in:


import arcpy
import pythonaddins


class ButtonClass1(object):
      """Implementation for SelectByLocation_addin.button (Button)"""
      def __init__(self):
            self.enabled = True
            self.checked = False
      def onClick(self):
            pythonaddins.GPToolDialog(r"C:\AddIns\SelectByLocation\Install\mytoolbox.tbx", "SelectByLocation")


I have double, triple and quadruple checked the spelling, path name and locations of all the relevant files. Just for your info here's the code for the python tool itself but like I say there;'s no issue running it from the toolbox:


import arcpy

distancemerge=distance+" "+distancetype




If anyone can see what's wrong here I would very much appreciate any help with this.


Apologies for the formatting by the way. This is my first post and I can't figure out how to do the script boxes.Time to bang my head against a brick wall!