will_davis44

Making my Python code more dynamic

Discussion created by will_davis44 on Jun 27, 2012
Latest reply on Jun 27, 2012 by will_davis44
I wrote a script and want to implement it into a custom script tool.  This is my first time doing this, and from what I understand, since my script is hard-coded, I should use the GetParameterAsText() method to make it more dynamic and useable in a tool.
So, my question is when i set my variables to the GetParamaterAsText() with the numbered values, when I reference those variables through the code do I go back and use the same value in the GetParamAsText()?

For example, here I reference PlantSiren as (1).

#Name- Route_Analysis.py
import arcpy
#Set geoprocessing environment
inWorkspace = arcpy.GetParameterAsText(0)
arcpy.env.workspace = inWorkspace
arcpy.env.overwriteOutput = True

#Variables
PlantSiren = arcpy.GetParameterAsText(1)
ROUTE_ALERT_SECTORS = arcpy.GetParameterAsText(2)
bufferOutputFinal = "G:\\deptdata\\DES\\Staff_Workspace\\WDavis\\Route_Alert\\Route_Alert_Analysis.gdb\\bufferOutputFinal"
newIntersectFinal = "G:\\deptdata\\DES\\Staff_Workspace\\WDavis\\Route_Alert\\Route_Alert_Analysis.gdb\\newIntersectFinal"


When I reference PlantSiren here in my buffer, do I replace it with GetParamaterAsText(1) or do I keep incrementing the method so that it would be GetParamaterAsText(3)?
#Create a buffer
arcpy.Buffer_analysis("PlantSiren", bufferOutputFinal, "1 Mile")


I can't seem to find any good examples on the internet.  If anyone could be of assistance it would be greatly appreciated!

Thanks

Outcomes