I have been working on exporting attachments from a point feature class by location (County). The export is renamed by the area (County), which contains the feature class, attachment table, and the relationship class, using this:
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> os<SPAN class="punctuation token">,</SPAN> datetime<SPAN class="punctuation token">,</SPAN> traceback<SPAN class="punctuation token">,</SPAN> sys
Start <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Running Elevation Certificate by County Export '</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Set Environmental Setting</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>maintainAttachments <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token"># Select County polygons and export to folder</SPAN>
DOMAIN_COUNTIES_TABLE <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"S:\Projects\CFI_Models\USNG_Demographics_Statewide\Domain_Counties.gdb\DOMAIN_COUNTIES"</SPAN>
DOMAIN_COUNTIES_Descript <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Descript"</SPAN>
DOMAIN_COUNTIES_CURSOR <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SearchCursor<SPAN class="punctuation token">(</SPAN>DOMAIN_COUNTIES_TABLE<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> DOMAIN_COUNTIES_CURSOR<SPAN class="punctuation token">:</SPAN>
COUNTIES_DESCRIPT <SPAN class="operator token">=</SPAN> row<SPAN class="punctuation token">.</SPAN>getValue<SPAN class="punctuation token">(</SPAN>DOMAIN_COUNTIES_Descript<SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token">#Feature Class to Geodatabase</SPAN>
infc <SPAN class="operator token">=</SPAN> <SPAN class="string token">"T:\Projects\Elevation_Certificates\ECs_Hosted_20200929.gdb\ELEVATION_CERTIFICATES"</SPAN>
outgdb <SPAN class="operator token">=</SPAN> <SPAN class="string token">"T:\Projects\Elevation_Certificates\ECs_Archive_by_County.gdb"</SPAN>
where_clause <SPAN class="operator token">=</SPAN> <SPAN class="string token">"\"COUNTY_COMMUNITY\" = '%s' "</SPAN> <SPAN class="operator token">%</SPAN>COUNTIES_DESCRIPT
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Exporting: "</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">'%s'</SPAN> <SPAN class="operator token">%</SPAN>COUNTIES_DESCRIPT<SPAN class="punctuation token">)</SPAN>
StartTime <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>FeatureClassToFeatureClass_conversion<SPAN class="punctuation token">(</SPAN>infc<SPAN class="punctuation token">,</SPAN> outgdb<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"%s"</SPAN> <SPAN class="operator token">%</SPAN>COUNTIES_DESCRIPT<SPAN class="punctuation token">,</SPAN> where_clause<SPAN class="punctuation token">)</SPAN>
EndTime <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
DeltaTime <SPAN class="operator token">=</SPAN> EndTime <SPAN class="operator token">-</SPAN> StartTime
TimeDiff <SPAN class="operator token">=</SPAN> str<SPAN class="punctuation token">(</SPAN>DeltaTime<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Process Time: '</SPAN> <SPAN class="operator token">+</SPAN> TimeDiff<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Completed County Feature Class Export '</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
End <SPAN class="operator token">=</SPAN> datetime<SPAN class="punctuation token">.</SPAN>datetime<SPAN class="punctuation token">.</SPAN>now<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
Delta <SPAN class="operator token">=</SPAN> End <SPAN class="operator token">-</SPAN> Start
Time <SPAN class="operator token">=</SPAN> str<SPAN class="punctuation token">(</SPAN>Delta<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Process Time: '</SPAN> <SPAN class="operator token">+</SPAN> Time<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>This yields everything I need but loses the relationship. Any ideas how to rebuild this relationship or how to successfully export the data that carries the relationship class?
Thanks,
Daniel