1

I have a multiple Python scripts that act as geoprocessing tools. I have an ArcGIS Pro Toolbox (.atbx format) defining how to call them. The scripts are in a subdirectory of the location where the .atbx file is stored. I want to be able to move around the directory containing the .atbx file and .py files and have them go on working.

According to the ArcGIS Pro documentation Add a script tool:

If your toolbox is an ArcGIS toolbox (.atbx), this behavior is managed differently. If the script is in the same directory as the .atbx file or is in a child folder from where the .atbx is stored, a relative path is maintained. If the script and .atbx file are completely separate, an absolute path is maintained.

However, I have not seen this happen as described above. I have tried putting the .py files in various locations, including the same folder as the .atbx file. The path to the .py file is always absolute.

I see that the .atbx file format is a zipped archive where each tool gets a .tool directory containing a file called tool.script.execute.link. I have opened this after trying various .py locations and it always shows an absolute path. I tried manually editing it to use a relative path, but the next time I modified anything about the tool in the .atbx file it switched back to an absolute path.

My organisation is using ArcGIS Pro 2.9 for compatibility reasons, if this makes a difference.

So, can I get these .atbx files to store a relative path to my scripts?

Other options if ArcGIS Pro simply won't do this with .atbx files:

  • The scripts are long and under version control, so I don't consider storing them inside the .atbx satisfactory.
  • I could use the legacy toolbox (.tbx) format, but this may be removed from some future version of ArcGIS Pro.
  • In similar circumstances I have used the Python Toolbox (.pyt) format and it has been unwieldy but functional. It remains an option if there is no way to use the .atbx.

1 Answer 1

1

Sounds like a version issue if you are stuck at 2.9. I just set up a toolbox with a tool pointing to a py file in a sub-folder, moved atbx file and folder into a completely different drive space and it worked as intended. I'm using ArcPro 3.2.1.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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