I have a python script in ArcGIS 10 that when clicked, has a popup for a user to choose parameters. I would like to send this file to someone else. While I could send them the python code and have them setup the parameters - this method repeats work I have already done.

I would like to send someone one file that contains all of this information so they can just recieve my file, add it to a toolbox, and then have it all work. I am wondering where the file resides that has both the python code and parameters / what is the export process/ file type I should be looking at? (All the searches I do for "export script" seem to refer to exporting a model to python code...)


Yes, as per @Chad Cooper's answer, you send the custom toolbox (*.tbx file) and the python script. There are instructions in the online help to do this.

| improve this answer | |
  • 3
    Further to that, you can embed the Python script directly to the toolbox, even with an optional password for protection. – Mike T Jan 13 '12 at 20:01
  • I think this is the key info I was looking for. As a semi-aside: is there any way of looking at the properties of the toolbox to see if it has script embedded or not? – GIStack Jan 13 '12 at 21:22
  • interestingly this embed method does not seem to embed any code from my few tests... (when I went to open the toolbox from another computer) – GIStack Jan 13 '12 at 21:41
  • think i figured out why this did not work (see comment in response to blah238's answer) – GIStack Jan 13 '12 at 22:19

I think what you want to do is create a custom Toolbox tool and setup your parameters there. Then you would ship others your code along with the .tbx Toolbox file. See this section of the ArcGIS help.

enter image description here

| improve this answer | |
  • This is indeed how I have done it. But what you are saying is to pass along a python script and its popup interface, I need to send the whole toolbox rather than the actual script for someone to add to their own toolbox? – GIStack Jan 13 '12 at 18:01
  • Sending the whole toolbox indeed works! Just had to get over trying to find a way to export the script itself. Thanks – GIStack Jan 13 '12 at 19:54
  • Found out that is worked - but only to bring up the interface, but the tool itself didnt work - apparently I also need to embed the script – GIStack Jan 13 '12 at 21:24
  • @GIStack - I believe you can also just point the .tbx to wherever the script resides on disk. – Chad Cooper Jan 13 '12 at 22:21
  • indeed - sending two separate files, with the one being the script seems to be the only viable solution if I am using ArcGIS 10, and the other person is using ArcGIS 9 – GIStack Jan 13 '12 at 22:29

Instead of modifying your script tool and specifying default values, I would use ModelBuilder to do this.

  1. Create a ModelBuilder model in the same toolbox.
  2. Drop your custom script tool in.
  3. Fill out the parameters.
  4. For any variables that you want the user to be able to change, even though they have a default value, right click the variable and select "Make model parameter".
  5. Save the model.
  6. Send the toolbox and Python script file. You can also embed the Python script in the toolbox as @Mike Toews mentioned.

Also be sure to use relative paths in your model and script tool properties so that the script, model and script tool can find each other on the client's machine: enter image description here

| improve this answer | |
  • Do you mean that unless "relative paths" is selected because embedding the script to the toolbox, the tool won't work on a different computer? – GIStack Jan 13 '12 at 21:21
  • If you are NOT embedding the script, then the script referenced by the script tool will likely not be found on the client's file system, because the absolute path to the script on your machine would likely be different to the absolute path to the script on the client's machine. When you use relative paths then as long as the toolbox and script are kept together it will work on any machine. I am not sure about whether ModelBuilder will have trouble finding the script tool without relative paths checked if they are in the same toolbox, but I generally always check the box out of habit. – blah238 Jan 13 '12 at 21:31
  • Ok - i just tried both ways (absolute and relative) and neither work. I do not understand why using the "embed script" method did not embed anything (When I go to edit the script that i emailed myself to a different computer, the editor does not come up because there is nothing to edit)... I must be missing something here.. – GIStack Jan 13 '12 at 21:40
  • I think i figured out my problem - I was trying to open a toolbox with embedded code on ArcGIS 9. It seems that embedded script is only supported by ArcGIS 10. – GIStack Jan 13 '12 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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