I'm quite new to ArcGIS, and now I have to work on a script that goes through a list of feature classes to:
- add a field to their attribute table and
- fill that field with a number that I retrieve from somewhere else
When I execute the following statements in the ArcMap Python window or in a minimal standalone script, it works just fine:
table = "JS4A" arcpy.AddField_management(table, "BK_Code", "LONG") arcpy.CalculateField_management(table, "BK_Code", "1", "PYTHON_9.3", "")
I can then open the attribute table of that feature class in ArcMap and see that this field has been added and populated with all 1s, just as expected.
Now the weird thing is, when I run the exact same code in the complex production script, the field is added as well, but when I open the attribute table, all the values are
I managed to track the problem down to the following line of code in my production script, that comes before the part with AddField and CalculateField:
env.extent = desc.extent
desc is the return value of an
arcpy.Describe() call to some other, unrelated shapefile. All
CalculateField_management calls before that line will work fine, all calls after that line produce
<Null>. When I replace the above line with a line that sets the output extent to a hard-coded value, it works.
I don't understand this at all. Is this an ArcGIS bug?
Unfortunately I can't omit the above line because it is required in the production script.