The script inside the toolbox works properly when running alone. However when I open the toolbar in arcmap always a [Missing] Error. The following is my entire add-in .py? I cannot for the life of me figure out what is missing here?...
import os
import arcpy
import pythonaddins
relPath = os.path.dirname(__file__)
class ButtonClass1(object):
"""Implementation for Get IR Count_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
toolPath = relPath + r"\Custom Tools\Get IR Count\Install\GetIR.tbx"
pythonaddins.GPToolDialog(toolPath,"Get IR Count")
Solved! Go to Solution.
This was completely my fault these were all great responses and correct answers for what I have provided here! It turns out I was confusing the script name for script label.
Thus...
pythonaddins.GPToolDialog(toolPath,"GetIRCount")
instead of...
pythonaddins.GPToolDialog(toolPath,"Get IR Count")
Which is what is displayed in arc catalog.
Thank you both for your time and valuable input!!
Can you print relpath to see if it contains forward slashes or is in raw form and contains a backslash at the end. Also searching gptooldialog reveals some tips ie https://community.esri.com/message/75339?sr=search&searchId=c4e4a943-1567-4d2e-802c-abdaefd98d40&sea...
Thanks for jumping in Dan! Here are my results...
G:\Custom Tools\Get IR Count\Install
Which was not exactly as expected. I have revised and still missing?
import os
import arcpy
import pythonaddins
relPath = os.path.dirname(__file__)
class ButtonClass1(object):
"""Implementation for Get IR Count_addin.button (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
toolPath = relPath + r"\GetIR.tbx"
pythonaddins.GPToolDialog(toolPath,"Get IR Count")
If I'm reading your code correctly, then your TBX file lives at the top-level inside of your 'Install' directory. When you build an add-in, the files inside of 'Install' are all placed into a GUID-based directory within your users' home directory, and any paths should be relative to this. You can read more about using files from the 'Install' directory in the documentation, under the heading "File and folder structure".
So, the path to the toolbox should be something like:
toolPath = os.path.join(relPath, "getIR.tbx")
One way you can test this is by changing your code to just pop up a message box instead of executing the tool:
def onclick(self): pythonaddins.MessageBox("toolPath is set to {}.".format(toolPath), "Expected Path")
cheers,
Shaun
For some reason Shaun the messagebox displayed...
"toolPath is set to '\GetIR.tbx'
Should I see the joined path here?
Thanks Dan. Yeah that what I was working with. Still cant get past these results?
This was completely my fault these were all great responses and correct answers for what I have provided here! It turns out I was confusing the script name for script label.
Thus...
pythonaddins.GPToolDialog(toolPath,"GetIRCount")
instead of...
pythonaddins.GPToolDialog(toolPath,"Get IR Count")
Which is what is displayed in arc catalog.
Thank you both for your time and valuable input!!