Is there any way to call a script using the project's default toolbox parameter?
What works:
arcpy.ImportToolbox(path + r"\ArcGIS_Pro.atbx")
arcpy.ArcGISProatbx.SE4Polygons()
What I would like to do:
arcpy.ImportToolbox(project.defaultToolbox) #this part is ok
mytools = arcpy.ImportToolbox(project.defaultToolbox) #this is ok too
arcpy.project.defaultToolbox.SE4Polygons() # doesn't work
arcpy.mytools.SE4Polygons() # doesn't work
Thanks in advance!
Solved! Go to Solution.
arcpy.ImportToolbox(project.defaultToolboxk, "mytools")
arcpy.SE4Polygons_mytools(....
based on suggestions in...
Add toolboxes in Python—ArcGIS Pro | Documentation
arcpy.ImportToolbox(project.defaultToolboxk, "mytools")
arcpy.SE4Polygons_mytools(....
based on suggestions in...
Add toolboxes in Python—ArcGIS Pro | Documentation
I think you need to specify an alias for the toolbox on the fly, or set the alias beforehand in the tbx.
https://learn.finaldraftmapping.com/how-to-use-custom-tools-in-a-python-script-with-arcpy/
import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
#import toolbox with alias 'default_toolbox'
arcpy.ImportToolbox(aprx.defaultToolbox, 'default_toolbox')
#run SE4()
arcpy.default_toolbox.SE4Polygons()