How to get the directory path of the toolbox in ArcPy?

942
5
02-09-2023 12:12 AM
Labels (3)
NiharSahoo
New Contributor III

I want to access the file path inside the toolbox directory path, so I need to access the directory path of the toolbox. Please let me know how I would get it using ArcPy.

 

1.png

Tags (2)
0 Kudos
5 Replies
DanPatterson
MVP Esteemed Contributor

from arcpy mapping, the project has a "defaultToolbox" property which you can get or set

ArcGISProject—ArcGIS Pro | Documentation

defaultToolbox
(Read and Write)
The project's default toolbox location. The string must include the toolbox's full path and file name.

code examples are at the bottom of the help topic


... sort of retired...
0 Kudos
NiharSahoo
New Contributor III

But this will only give me the path of the toolbox associated with project only. I need to access the path of other toolbox path that has been added to the same project. 

0 Kudos
AngelaSchirck
Occasional Contributor II
0 Kudos
DanPatterson
MVP Esteemed Contributor

Use the ListToolboxes method in the project class 

No luck over there either

arcgis pro - How to get the directory path of the toolbox in ArcPy? - Geographic Information Systems...

so you might want to try a different approach if your toolboxes are stored in a common location

Solved: How to list all Toolboxes names in a specific fold... - Esri Community


... sort of retired...
0 Kudos
akreiger
New Contributor

Maybe this will get you closer to what you're looking for?
https://stackoverflow.com/questions/3430372/how-do-i-get-the-full-path-of-the-current-files-director...

The solution using os works within a python toolbox added to a Pro (version 3.1.2) project.

0 Kudos