I'm looking for a Python 3/Aracade script to field calculate ATT_NAME in an attachment table based off of the REL_GLOBALID.

So where REL_GLOBALID is {67CECF26-9BE8-4E37-9408-3BC156DA51C0}, I'd like to rename ATT_NAME to Photo 1 and then where there is another attachment with the same REL_GLOBALID, I'd like that to be changed to Photo 2. See attached photo

example photo


This task is very easily (and quickly) accomplished in ArcGIS Pro with an update cursor. See my practical example below. You can see the names updates between table 1 and table 2. You will need to adjust the fields variable at the top of the script, as well as adjust the 'test_table' name in the update cursor on line three. The 'test_table' can be replaced with a string of the name of your table in the current map document, or a string pointing to the path of the file on disk.

fields = ['GUID', 'ATT_NAME']
featureClass = 'test_table'
update_dictionary = {}

with arcpy.da.UpdateCursor(featureClass, fields) as updates:
    for row in updates:
        if row[0] not in update_dictionary.keys():
            update_dictionary[row[0]] = 1
            update_dictionary[row[0]] += 1
        row[1] = 'Photo ' + str(update_dictionary[row[0]])

BEFORE CODE enter image description here

AFTER CODE enter image description here

GIF OF PROCESS enter image description here

  • 2
    Oh I use ShareX! Dude, it is friggen AWESOME. getsharex.com
    – John
    Jan 26 '21 at 16:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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