[GIS] Pass a variable from Modelbuilder into a Python script

arcpymodelbuilderpython

I'm new to modelbuilder and python.
I have used modelbuilder to iterate through all rows in a shapefile (Points), process them, and produce a seperate output shapefile for each row. The filename is generated using an inline variable (I think that is the correct terminology). i.e. all output files have identical filenames except that the value of the PointID from the original input file is appended to the filename to enable them to be distinguished. This works fine.

I've also written a python script to take the above output files from the model one at a time and do additional processing. At present the input filename is hard coded into the script (i.e. I have to edit the script to change the input filename each time I run it). Again this works fine while just processing a single file. However, I want to integrate the model and the python script so that I can run the script for each row in the original feature class automatically.

My question is therefore, how do I replace the hard coded name of the input file with a variable in the python script and how do I pass the filename to the script.

Best Answer

In the script make point feature class variable provided as parameter:
inputPointFC = arcpy.GetParameterAsText(0)

Then create a script tool with one input parameter which uses your single point feature class as Default property. This feature class name should be provided with inline variable: PointFC_%Value%, where Value is name of iterator output.
Here's a picture example:
enter image description here