1

I'm add fields via arcpy code as follows;

import arcpy
arcpy.env.workspace = "C:\Users\sheartz\Documents\NBspray_1952.shp"
arcpy.AddField_management(
    'NBspray_1952', 
    [['area_ac', 'DOUBLE', None, 20, None, ''], 
     ['area_ha', 'DOUBLE', None, 20,None, ''],
     ['block_1', 'TEXT', None, 12,None, ''],
...more field entry code...
     ['citations', 'TEXT', None, 8,None, '']])

Error was stated as;

Runtime error 
Traceback (most recent call last):
  File "<string>", line 46, in <module>
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 3443, in AddField
    raise e
RuntimeError: Object: Error in executing tool

Not seen this error before, can't find what it means.

1 Answer 1

1

You need to read the help file and understand what the syntax section is telling, then look at the sample code to get a good understanding of how to call the tool.

At no point in the help does it indicate you can enter a list of fields as you have. It is AddField... singular!

The syntax you appear to be using is for the ArcPro AddFields tool...plural!

You've tagged your question as Arcgis 10.5 so there is only one tool you can use and that's the AddField tool.

1
  • Right, thanks. Sounds like I have to add one by one or switch to ArcPro! Lucky me. Appreciate the feedback. Commented Apr 20, 2021 at 16:32

Not the answer you're looking for? Browse other questions tagged or ask your own question.