Select to view content in your preferred language

Importing and running GP service works in Python window and Notebook but not Toolboxes?

178
0
03-25-2025 08:11 AM
AlfredBaldenweck
MVP Regular Contributor

Pro 3.3

I have a GP service that I'm trying to run from a toolbox.

The specific tool takes a layer object as its only input parameter.

I can run the following code just fine in the Python Window and in a Notebook, and it works great.

However, in a tool (ATBX, PYT), the code just skips past that line-- the entire thing takes like 2 seconds with no output instead of the 30+ it takes in a Notebook.

I can tell that it's feeding in correctly, since if I, for example, feed it a list instead of a layer, it throws an error because the parameter type is wrong.

Here is the code that I am using.

arcpy.ImportToolbox(r"toolboxURL;toolboxFolder")
aprx = arcpy.mp.ArcGISProject("CURRENT")
mp = aprx.activeMap
lay = mp.listLayers()[0]
arcpy.ToolBoxAlias.Tool(lay)

Does anyone have any idea of what's going on and how to fix this?

 

0 Kudos
0 Replies