Select to view content in your preferred language

Creating fields Attribute Table on ArcToolbox

773
3
06-02-2021 03:29 AM
Malebu
by
Emerging Contributor

Good day

I am having multiple layers (features) and I trying to standardize their attribute table. I am currently looking for a process or script that one could use to design a stand-alone attribute table "fields" within the Arc Toolbox. Meaning this tool I can add to my model and create standard fields within the attribute table. Could you please assist

Regards

Tsamaelo

0 Kudos
3 Replies
DavidPike
MVP Notable Contributor
0 Kudos
Malebu
by
Emerging Contributor

Thanks David. 

Reading through the info on the link you've sent, it's only given me an option to add individual fields. Please see the example below of what I would like to create. 

Malebu_0-1622631174056.png

 

0 Kudos
DavidPike
MVP Notable Contributor

I don't know of an existing tool you can use to make it less verbose, however it's still pretty simple copy paste stuff.  Something like

#your fc
in_table = arcpy.GetParameter(0)

#for each field
field_name1 = arcpy.getParameterAsText(1)
field_length1 = int(arcpy.getParameterAsText(2))

arcpy.management.AddField(in_table, field_name1, field_type, {field_precision},
                          {field_scale}, {field_length1}, {field_alias},
                          {field_is_nullable}, {field_is_required}, {field_domain})


field_name2 = arcpy.getParameterAsText(3)
field_length2 = int(arcpy.getParameterAsText(4))

arcpy.management.AddField(in_table, field_name2, field_type, {field_precision},
                          {field_scale}, {field_length2}, {field_alias},
                          {field_is_nullable}, {field_is_required}, {field_domain})
0 Kudos