<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic ArcGIS Pro relationship class attachment in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192137#M57227</link>
    <description>&lt;P&gt;I downloaded a feature class with attachments from AGOL using this guide&amp;nbsp;&lt;A href="https://support.esri.com/en/technical-article/000012232" target="_blank"&gt;How To: Download attachments from a hosted feature service (esri.com)&lt;/A&gt;. Then, I downloaded the attachments with the script described here&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-online-questions/how-do-i-download-all-arcgis-online-attachments/td-p/711341" target="_blank"&gt;How do I download all ArcGIS Online attachments fr... - Esri Community&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I had to rename all of the values in "ATT_NAME" because they were all called either Photo 1.jpg or Photo 2.jpg.&lt;/P&gt;&lt;P&gt;Now I have been asked whether it is possible to rename them with a name given in a field in the original feature class. I thought it might be possible since they are connected with the relationship class&amp;nbsp; ("_ATTACHREL"), but can't figure out how.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very grateful for any help, thanks!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jul 2022 07:54:38 GMT</pubDate>
    <dc:creator>IlkaIllers1</dc:creator>
    <dc:date>2022-07-14T07:54:38Z</dc:date>
    <item>
      <title>ArcGIS Pro relationship class attachment</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192137#M57227</link>
      <description>&lt;P&gt;I downloaded a feature class with attachments from AGOL using this guide&amp;nbsp;&lt;A href="https://support.esri.com/en/technical-article/000012232" target="_blank"&gt;How To: Download attachments from a hosted feature service (esri.com)&lt;/A&gt;. Then, I downloaded the attachments with the script described here&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-online-questions/how-do-i-download-all-arcgis-online-attachments/td-p/711341" target="_blank"&gt;How do I download all ArcGIS Online attachments fr... - Esri Community&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;I had to rename all of the values in "ATT_NAME" because they were all called either Photo 1.jpg or Photo 2.jpg.&lt;/P&gt;&lt;P&gt;Now I have been asked whether it is possible to rename them with a name given in a field in the original feature class. I thought it might be possible since they are connected with the relationship class&amp;nbsp; ("_ATTACHREL"), but can't figure out how.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would be very grateful for any help, thanks!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 07:54:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192137#M57227</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2022-07-14T07:54:38Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro relationship class attachment</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192291#M57245</link>
      <description>&lt;P&gt;I use the following code to do just that.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this case, all my attachments are .jpg files, so I just append that filename extension.&amp;nbsp; If you have other/mixed file types, would need to modify to extract that info from the _ATTACH table.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

inFeatureClass = r'Database Connections\...\Signs'         # feature class with attachments
pointFieldsList = ['GlobalID','MUTCDcode']                 # fields to load into cursor

global_dict = {}                                           # dictionary to hold globalIDs and "name" field

fileLocation = r'C:\tmp\Attachments'                       # folder where attachments are saved


with arcpy.da.SearchCursor(inFeatureClass, pointFieldsList) as point_cursor:  # cursor to make dict of globalID's
        for row in point_cursor:
          if row[1]:
            row1 = row[1]                                 # I'm using "MUTCDcode" as my name field, but is
          else:                                           # not always populated.  if Null, substitute "NA"
            row1 = "NA"
          global_dict[row[0]] = [row[0],row1]             # add to dict with globallID as key, name as value


inTable = r'Database Connections\SignDatabase.sde\SignsDatabase.DBO.Sign__ATTACH'   #  attachment table for feature class
tableFieldsList = ['REL_GLOBALID', 'DATA', 'ATT_NAME', 'ATTACHMENTID']              # field list in attachment table


with arcpy.da.SearchCursor(inTable, tableFieldsList) as table_cursor:
    for item in table_cursor:
        attachment = item[1]                                                        # grab attachemnt from blob field
        filename = global_dict[item[0]][1] + '_' + str(item[3]) + '.jpg'            # create filename from value in FC dict that has matching GlobalID
        open(fileLocation + os.sep + filename, 'wb').write(attachment.tobytes())    # write the attachment as a file.
        &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;R_&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2022 18:37:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192291#M57245</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2022-07-14T18:37:39Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro relationship class attachment</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192811#M57329</link>
      <description>&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 06:29:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-relationship-class-attachment/m-p/1192811#M57329</guid>
      <dc:creator>IlkaIllers1</dc:creator>
      <dc:date>2022-07-18T06:29:54Z</dc:date>
    </item>
  </channel>
</rss>

