AnsweredAssumed Answered

Problem with attachments in arcpy

Question asked by n.ueberschaeresri-rw-esridist Employee on Sep 5, 2017

I didn't really know how to word my question in only a few words for the head line... Let me try to explain my problem: 

 

I have a script that attaches .png files to point features. The idea is to have those files matched to the point that have the same UID as the point. 

 

def AddAttachmentsToUid():
    arcpy.GenerateAttachmentMatchTable_management(_location_for_points, _location_for_attachments,
          _matchtable, "UID","*.png", "ABSOLUTE")
    arcpy.AddAttachments_management(_location_for_points, "OBJECTID", _matchtable, "MatchID", "Filename")

 

UIDs look e.g. like KivuWatt_151113_9 - the last number is ranging in this case from 1 to 16. 

While it works perfect for all other files I tested so far, I have a problem with the files KivuWatt_151113_1 and KivuWatt_151113_10 up to ..._16 which are all attached to the point with the UID KivuWatt_151113_1 (and then again to the correct point). 

 

For your information (in case it matters): The png files store also a specified range in the file name, e.g. KivuWatt_151113_1_0-400.png

 

Edit: It is somehow understandable since the tool compares the uid with the file names and as long as they start with the same characters it matches them. So I think the best would be to compare the uid from the feature class with uid+_+*.png in the files, but how can a specify this within the GenerateAttachmentMatchTable_management tool?

Outcomes