Saturday 24 October 2015

arcpy - Pass a variable from Modelbuilder into a Python script


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.





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...