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.
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
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.
https://desktop.arcgis.com/en/arcmap/latest/analyze/python/adding-and-removing-toolboxes.htm
Not sure if this will help.
Use the ListToolboxes method in the project class
No luck over there either
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
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.