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.

menes
1,4272 gold badges8 silver badges25 bronze badges
asked Apr 20, 2021 at 15:53

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.

answered Apr 20, 2021 at 16:26
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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.