I guess you would need a physical field in you attribute table that indicates if the feature has an attachment. You could do the following:
- add a new field
- calculate the field like this:
This is the code used:
def hasAttachment(oid):
fc = r"D:\Xander\GeoNet\Attachments\test.gdb\test"
att = "{0}__ATTACH".format(fc)
fld_reloid = "REL_OBJECTID"
lst_relOID = list(set([r[0] for r in arcpy.da.SearchCursor(att, (fld_reloid))]))
return 1 if oid in lst_relOID else 0
The bad thing is that you would have to change the reference on line 2 where the path and name of the featureclass is indicated (I don't know how to access the path to the fc from the field calculator). The other thing is that every time you update attachments, you will have to recalculate. You will need to be in an edit session to calculate the field.
The result is a field that has value 1 for those features with attachments and value 0 for those that don't.
Kind regards, Xander