pythonaddins.GPToolDialog() Missing?

4387
7
Jump to solution
07-29-2014 01:23 PM
NoahHuntington
Occasional Contributor

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")

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
NoahHuntington
Occasional Contributor

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!!

View solution in original post

0 Kudos
7 Replies
DanPatterson_Retired
MVP Emeritus

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...

NoahHuntington
Occasional Contributor

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")

0 Kudos
ShaunWalbridge
Esri Regular Contributor

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

NoahHuntington
Occasional Contributor

For some reason Shaun the messagebox displayed...

"toolPath is set to '\GetIR.tbx'

Should I see the joined path here?

0 Kudos
NoahHuntington
Occasional Contributor

Thanks Dan. Yeah that what I was working with. Still cant get past these results?

0 Kudos
NoahHuntington
Occasional Contributor

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!!

0 Kudos