Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have made a set of tools in a toolbox using ArcGIS 10.2 using the model builder.

I would like to distribute them as a tool bar, and so created a ArcGIS Python Add-In I was hoping that I could export the tools as python scripts and copy the code into the Add-In. However, it does not seem to be as simple as that.

Is it possible with Python Add-Ins to make a window for entering in parameters and run a script in the way tools/toolboxes work?

Update

I found a useful blog post.

This is my code

import arcpy
import pythonaddins
import os.path

class multiplebenefits(object):
    """Implementation for ArcGISAddin_addin.multiplebenefits (Tool)"""
    def __init__(self):
        self.enabled = True
        self.checked = False

    def onClick(self):
       # name of toolbox without tbx extension
       toolboxName = "mytoolbox"
       # name of tool to be executed
       toolName = "mymodel"
       # create string with path to toolbox
       toolboxPath = os.path.join(os.path.dirname(__file__), toolboxName + ".tbx")
       # call geoprocessing tool
       pythonaddins.GPToolDialog(toolboxPath, toolName)

But I get an error message:

Failed to open tool mymodel (mytoolbox.tbx)

TypeError: GPToolDialog() takes at most 1 argument (2 given)

share|improve this question
1  
It's saying it can't find the toolbox, what is the value of __file__ and is the toolbox there? Perhaps hard-code the path to the toolbox to see if that's what's causing the problem for now and fix it up before distributing. The documentation says it's possible and this looks fairly close to the bottom example on resources.arcgis.com/en/help/main/10.1/index.html#//… so I can't see why it wouldn't work should it be able to find the toolbox. –  Michael Miles-Stimson Apr 17 at 1:38

1 Answer 1

up vote 0 down vote accepted

The TypeError: GPToolDialog() takes at most 1 argument (2 given) error was caused by an error in the toolName value, this is not the name as it appears in the tool box, it must be set in the Model Properties.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.