话不多说,上脚本源码,复制黏贴即可
__author__ = 'lumen'
import arcpy
InputFeature = arcpy.GetParameterAsText(0)
oldField = arcpy.GetParameterAsText(1)
oldFieldType = ''
desc = arcpy.Describe(InputFeature)
fields = desc.fields
arcpy.AddMessage(fields)
for field in fields:
if field.name==oldField:
oldFieldType = field.type
arcpy.AddMessage(oldFieldType)
newField = arcpy.GetParameterAsText(2)
arcpy.AddMessage('fields has been registered')
arcpy.AddField_management(InputFeature, newField, oldFieldType)
cursor = arcpy.UpdateCursor(InputFeature)
for row in cursor:
newValue = row.getValue(oldField)
row.setValue(newField,newValue)
cursor.updateRow(row)
arcpy.DeleteField_management(InputFeature, oldField)
arcpy.AddMessage('project succeed,best wishes for you')
del cursor, row
安装后界面这样