Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a .tbx tool box, which runs a script that is incredibly slow. So what I want to do is to open the python script that is running below the .tbx and make some changes or perhaps write something similar and faster. Is there someway to convert a .tbx ( and not just the form ) into a .py so I can inspect the code that it runs? to clarify,

it is a third party tool created as a .tbx, and specifically here:

it is slow in running in arcmap, but that is not the central idea, here. I want to open the python underneath the .tbx. As suggested by others i have tried to right click and export (grayed out) and also i have tried using a .tbx to .pyt converter (only returns the input form) and one more thing i has also right clicked and opened in wordpad, but it was nearly illegible.

share|improve this question
Is the python script (.py) not in the folder with the toolbox (.tbx)? If not, check the properties to the script tool which will tell you where to find the source script file. Also, the code may have been imbedded into the toolbox. If this is the case, you can right-click the tool, and export the script. Be aware that it may be password protected. – Barbarossa Jun 9 '14 at 20:38
export is grayed out and the properties for the script do not show a location for a .py file. I think I am outta luck, no? – fargreenhills Jun 9 '14 at 20:55
Have you tried opening the toolbox in a text editor? If you can't find the .py file that should have come with it, then it's probably embedded as @Barbarossa mentioned. – Paul Jun 9 '14 at 21:01
I'll give that a go! thanks for the info! – fargreenhills Jun 9 '14 at 21:05
Are you referring to ESRI tools, or script tools created by third-parties and attached to a python toolbox? – Aaron Jun 9 '14 at 21:09
up vote 5 down vote accepted

For third party toolboxes, there will either be an associated python script or the script will be embedded. Check the properties of the tool to see if there is a source script file. If embedded, right-click to export script. There may be password protections.

If it is not a tool, and it seems in this case a model tool, the model can be viewed and modified in model builder. Simply right-click and edit. From model builder, you can also export the script to modify or use in a python script tool.

share|improve this answer

I'm not entirely sure if I understand your question, it leaves itself open to a few interpretations.

  • The Python itself is slow: You don't need to do any conversion. Just use the standard profiling tools the Python Standard Library offers to get some insight as to what's running slow.
  • The bookkeeping of the Geoprocessing tool is slow: If the set up and tear down of the tool is the issue, then you're mostly out of luck. All of that happens in the ArcObjects level.
  • The tool runs slow in general, and you want a Python dump of everything involved: Pretty much the source of the script tool is all the Python involved in your script tool. From there it's C++ the rest of the way down, which doesn't translate to Python.

If you want a little more control over seeing what goes on, you can use this tool to convert your TBX files to PYTs. It will also consolidate the Python source of all the scripts in your toolbox into the single file as well.

If you want more control over what goes on from there, you're going to have to go into ArcObjects. Very little of the implementation of the framework for running Python tools is actually implemented in Python.

share|improve this answer
and fair enough it was a bit cryptic. however, my issue is that I want to see the code behind the .tbx file to determine where I could implement some faster processing options. i cannot right click the code and export nor is there a location of the .py file in the properties so it must be embedded as barbarossa and Paul mentioned – fargreenhills Jun 9 '14 at 21:05
@fargreenhills Don't forget that you can always edit your Question to make what you are asking clearer. Comments here are intended to elicit clarifications to your original Question rather than to form a discussion. – PolyGeo Jun 9 '14 at 21:21

Your Answer


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.