All,
I am developing a suite of python script tools in the ArcPro 3.1.0 toolbox (atbx). A set of these tools create a stand alone table in a file geodatabase whose location is known to the tool. The user has no control over name or output location, this is controlled in the script itself. The code runs without error and creates the table as expected. I expose this table created in the script as a derived output as shown below:
In my script I create the table, fill it with the required data and add it to the map, I also set the 4th parameter to it, the relevant add to map code is shown below:
try:
aprx = arcpy.mp.ArcGISProject("CURRENT")
mainMap = aprx.activeMap
errorTable = arcpy.mp.Table(sPathTable) # sPathTable is a full path to the file geodatabase table
mainMap.addTable(errorTable)
arcpy.SetParameter(4, sPathTable)
except:
arcpy.AddError("Failed to add table to map, this functionality only works if tool is run from within an active ArcPro Project")
return
When the tool is run straight from the toolbox, all seems to run OK. If I drag 'n' drop it into a model and then link the derived output to say another tool (in the example below it's an add field tool) the linked tool never validates and the model won't run to completion.
I feel its something to do the derived output schema and the Add field tool doesn't know what's linking into it? There is the schema property of a parameter but all the examples in the help I've been able to find talk about setting the schema of an output that is dependent on an input parameter. My parameter is populated with a table built entirely within the script.
Does anyone understand what the problem is and can provide any advice? My gut feeling its something that needs to be added to the Validation (ToolValidator code)? Or are derived parameters meant to be "un-linkable"?