Skip to main content
Turned title into a question
Link
PolyGeo
  • 65.2k
  • 29
  • 109
  • 340

GetParatersAsText of a Field and How to use the Field Value from arcpy.GetParameterAsText()?

edited tags
Link
PolyGeo
  • 65.2k
  • 29
  • 109
  • 340
Source Link

GetParatersAsText of a Field and use the Field Value

I want to to is have a user select a feature class, which then populates the fields that can be selected (this works), create a new field in that feature (works), and then populate the new field with values based on the inputField values. Right now, it just populates the new field with the field name of the inputField.

It seems like this question has been asked a thousand times, but I still can't get this to work.

import os
import arcpy
from arcpy import env
env.overwriteOutput = 1  

inputFC = arcpy.GetParameterAsText(0)
inputField = arcpy.GetParameterAsText(1)
inputFieldLabel = "GeoLabel"
output = arcpy.AddFieldDelimiters(inputFC, inputField)
inputFieldName = arcpy.GetParameterAsText(2)

#Add the GeoLabel field to the Selected Feature Class
arcpy.AddField_management(inputFC, inputFieldLabel, "TEXT")

#Calculate the field values for the selected field, using UniueID field and InputFieldName
arcpy.CalculateField_management(inputFC, inputFieldLabel, output, "Python_9.3")