4

I have created a Python script tool using ArcPy. It has a File Geodatabase Table as output.

I want to add the script to a new Model in ModelBuilder in ArcMap. The Table output should be an "Intermediate" file in the Model. When I tried to right click on the Table to set "Intermediate" I noticed that option was greyed out.

In ModelBuilder, how can I set the Table to be "Intermediate".

...

Output_file_geodatabase = arcpy.GetParameterAsText(0)
Output_table_name = arcpy.GetParameterAsText(1)
Template_Table_Name = arcpy.GetParameterAsText(2)

arcpy.CreateTable_management(Output_file_geodatabase, Output_table_name, Template_Table_Name, "")

... use InsertCursor to add rows to the Table ...

arcpy.SetParameter(3, Output_file_geodatabase + "\\" + Output_table_name)

So here, there are three input params and one output param which is the Table.enter image description here

1 Answer 1

1

You need to right-click the output of the script and choose Intermediate. More info about that here, at Esri Help.

enter image description here

UPD: if the Intermediate option is greyed out, you have to make sure these things are true:

  1. The parameter for your output table in the Python script tool is Optional/Required (not Derived).
  2. You have the output table actually connected as input data for the tool in the model.

Here is the working model: enter image description here

Here is the Python script code behind:

import arcpy

out_t = r"C:\Geocoding\Atlanta.gdb\altnameOUT"
arcpy.CopyRows_management(r"C:\Geocoding\Atlanta.gdb\altname",
                          out_table=out_t)

arcpy.SetParameter(0,out_t)

NB: you need to run your model outside of ModelBuilder to get your intermediate data deleted (ie run the model from a toolbox).

6
  • Thanks Alex. But the issue is that the "Intermediate" option was greyed out in Model Builder when I right clicked on the Table. So the question is how to enable "Intermediate" option.
    – alextc
    Jan 22, 2016 at 4:35
  • Can you add more details on how the model looks like, what are the output parameters of the Python script? Add this into the question please. Jan 22, 2016 at 4:53
  • I'm not certain but I think you need to have an arcpy.SetParameterAsText() in your Python script tool for that option to be available. Perhaps create a test Python script tool and a test model that uses it, to play around with and include as part of your question.
    – PolyGeo
    Jan 22, 2016 at 5:10
  • Yes, I have already set up "SetParameter" in the Python script. The output file is the Table, also set in the Script.
    – alextc
    Jan 22, 2016 at 5:14
  • I wonder whether that option needs a Text object rather than Table object. Did you try arcpy.SetParameterAsText() as well?
    – PolyGeo
    Jan 22, 2016 at 5:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.