Select to view content in your preferred language

Creating a new Python tool is too complicated

1200
11
08-13-2011 05:24 PM
KimOllivier
Honored Contributor
I tend to create a new tool in a 'top-down' process:

  • Create a new toolbox

  • Add a new tool

  • Add in the parameters

  • Edit the documentation for the general purpose

  • Open the script to start writing

At Win 7 this has got even harder if you do not have Administrator access to streamline Windoze.

"Adding" a script is not appropriate because I have yet to create the script.
It would be useful to be able to create an empty file with a py suffix right there.

In the absence of a create, you can open the folder with the common dialog and create a text file on the fly and change the name and extension. Then select your new file. But this is impossible unless file extension types have been made visible in Windows control panel. This could also be eased if a file type of Python script was added to the registry so you could create a python script file as an option.

The only other way is to open PythonWin separately and save a script before you start a new tool.
That is not very integrated and is confusing when teaching students. It should be possible to work entirely inside ArcMap to manage the whole toolbox/scripting process.
Tags (2)
0 Kudos
11 Replies
MoragHawkins
Emerging Contributor
Right now what we have in terms of simple dialogs are available with the pythonaddins module. With this module you have the ability to open a dialog which the user can browse to select one or more datasets and return the path of the users selection to the tool. The same can be done so the user can save the path of a new dataset. You can also create a message with optional buttons such as Yes/No, OK/Cancel to get the users input.


Thanks for the reply Chris, but this still doesn't really cover it. Perhaps I should add this into ideas.esri.com once we can post outside of the beta community?

FYI a couple of use cases that spring to mind, plenty others no doubt.

1) I want to create an autosave add-in app extension. The user is given a number of options/setup config to control how auto save will work, do they want to autosave every x minutes, and if so how many minutes, or do they want to to only save on all ToC changes inc symbology, only on layers added, only on layers deleted etc, do they want it to pause if they are in an edit session....

You cannot achieve this via multiple ok/cancel prompts, or a toolbar full of menus and toggle buttons or combos (well you could but it would look pretty bad)

2) You have a custom buffer add-in tool written to interact with a particular datamodel. Options would specify how much category A features would be buffered within the tool selection/extent, how much category B would be buffered, category C and so on

Again you cannot really achieve this at present.

Perhaps if it were to go into ideas.esri.com, I would suggest that the same approach as getParamterInfo() from python toolboxes is used, you can read and write arcpy.Paramater() from within an add-in, with a parameter dialog that comes up similar to a toolbox.
0 Kudos
ChrisFox3
Frequent Contributor
Yes, I would definetly encourage you to post this on the ideas site once the 10.1 resource centers are opened up to everyone.
0 Kudos