Use script tool output parameter in model builder

433
2
Jump to solution
11-21-2022 07:59 AM
JulietteLapeyre
New Contributor II

I created a model builder which produce a summary statistics table, and a script tool which use this table in input, and tranpose it the way I whish to display results. I then want to join the reformated table from script tool, to a layer.

The issue is that the output of the script tool is not created, and I don't understand why.

JulietteLapeyre_2-1669046344486.png

 

1) summary statistics table created in the model builder

iddisruptive_elementdisruptive_surface
29cp800
29rb500
29aut300
30cp400

 

2) transposed table, produced in the script tool

idcprbaut
29800500400
3040000

I defined the input and output parameters in the script tool properties, and wrote the script in the execution tab.

JulietteLapeyre_0-1669046011935.png

JulietteLapeyre_1-1669046066652.png

 At the end of the script, there are the following lines. the csv is saved, but the table is not created in the geodatabse.

 

 

# Set local variables
out_name = "outStats.csv"
saving_path = os.path.join(homeFolder, out_name)
pivot_df.to_csv(saving_path, sep=',', index=True)

arcpy.MakeTableView_management(in_table=saving_path, out_view='viewtemp')
outTab = arcpy.TableToTable_conversion('viewtemp', defaultGDB, 'tempTable')
arcpy.SetParameter(1, outTab)

 

 

3) Join the previous table to a polygon layer, which contains the ids

this step doesn't work yet

0 Kudos
1 Solution

Accepted Solutions
JulietteLapeyre
New Contributor II

Hi Jeff,

yes it is correct. sys.argv[i] starts from 1, and Get/SetParameter[i] starts from 0.

It works now, I forgot to check 'add to display' in my model builder...

View solution in original post

0 Kudos
2 Replies
by Anonymous User
Not applicable

are the sys.args[i] indexing in your execution code correct? Should they be 0 and 1 perhaps?

0 Kudos
JulietteLapeyre
New Contributor II

Hi Jeff,

yes it is correct. sys.argv[i] starts from 1, and Get/SetParameter[i] starts from 0.

It works now, I forgot to check 'add to display' in my model builder...

0 Kudos