I fear I am missing something fundamental.
I can get a list of fields from one layer using ListFields, and look at the properties:
fields = arcpy.ListFields(feature_class)
# Iterate through the list of fields
for field in fields:
# Print field properties
print("Field: {0}".format(field.name))
print("Alias: {0}".format(field.aliasName))
print("Type: {0}".format(field.type))
print("Is Editable: {0}".format(field.editable))
print("Required: {0}".format(field.required))
print("Scale: {0}".format(field.scale))
print("Precision: {0}".format(field.precision))
Is there an easy way to add these fields with the exact same properties to a new layer using AddField_management?
I was hoping I could pass the field object directly and not have to decompose it into the individual properties. But the following does NOT work:
for field in fields:
# add fields with the same properties
arcpy.AddField_managment(feature_class2,field)
It does not seem very efficient to break out and pass every field property (field.name, field.type, etc). Surely there is a better way.
I get the error:
ERROR 000623: Invalid value type for parameter field_name