AnsweredAssumed Answered

Creating model tool from python script

Question asked by dubois2 on Jul 22, 2014
Latest reply on Jul 23, 2014 by dubois2

I have created a script that renames feature class aliases of existing fields. Is it possible to create a model tool that will take in a feature class as the input parameter and change the fields accordingly? All of the feature classes would have very similar fields to be changed. I can do it to every feature class individually, but I would rather attach this to the end of a model tool that is already created so it automatically renames the fields.

 

Here is my script:

 

fc = 'W:\Reference\Data\MapReady\GSA_2013Q4\GSAextract.gdb\CSA2013Q4_Tract'

 

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_TRACT","TRACT","Geography")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_QTR","QTR","Quarter")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_MEMBERS","MEMBERS","# mbrs")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_MALE","MALE","# KP mbrs MALE")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_FEMALE","FEMALE","# mbrs FEMALE")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_LANG_TOTAL","LANG_TOTAL","# mbrs with reported spoken language")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_LANG_ENGLISH","LANG_ENGLISH","# mbrs who prefer spoken English")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_LANG_SPANISH","LANG_SPANISH","# mbrs who prefer spoken Spanish")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_LANG_CHINESE","LANG_CHINESE","# mbrs who prefer a spoken Chinese dialect")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_LANG_OTHER","LANG_OTHER","# mbrs who prefer a different spoken language")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_INTRPTR_TOTAL","INTRPTR_TOTAL","# mbrs with reported interpreter needed")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_INTRPTR_YES","INTRPTR_YES","# mbrs who need interpreter")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_INTRPTR_SPANISH","INTRPTR_SPANISH","# mbrs who need Spanish interpreter")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_INTRPTR_CHINESE","INTRPTR_CHINESE","# mbrs who need a Chinese dialect interpreter")

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_INTRPTR_OTHER","INTRPTR_OTHER","# mbrs who need an intperpreter for another spoken

arcpy.AlterField_management(fc, "GSA_TRACT_copyR_PR_WHITE","PR_WHITE","# mbrs where race/ethnicity is White only (non-Hispanic)")

Outcomes