<?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 Re: Python and Relates in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338115#M26543</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, there is some good information on this topic in StackExchange:&amp;nbsp; &lt;A href="http://gis.stackexchange.com/questions/50287/how-can-i-more-efficiently-select-related-records"&gt;How can I more efficiently select related records?&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Oct 2014 18:45:32 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2014-10-30T18:45:32Z</dc:date>
    <item>
      <title>Python and Relates</title>
      <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338112#M26540</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am new to Python, so this may have a simple answer.&amp;nbsp; This is something that I used to write in AML in 10 minutes.&amp;nbsp; I want to relate a feature class to a table, select all records in the feature class - which would select related records in the table, do a switch selection on the table and create a new feature from the table.&amp;nbsp; My script does what it is supposed to when I use a small sample set, but totally crashes ArcMap so that it closes completely about 1/4 of the way through the full (13,000) records.&amp;nbsp; I believe it has something to do with the nested cursors that I have going.&amp;nbsp; How can I keep it from crashing and closing and finish the script?&amp;nbsp; Any help would be great!&amp;nbsp; Or if there is an easier way to do a relate in python??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the piece where is does a "relate" and ArcMap closes..........&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14146902886268819 jive_text_macro" jivemacro_uid="_14146902886268819"&gt;
&lt;P&gt;# Create a search cursor to loop through the building_pt_sewer table&lt;/P&gt;
&lt;P&gt;arcpy.SelectLayerByAttribute_management("building_clip", "NEW_SELECTION", "OBJECTID &amp;gt; 0")&lt;/P&gt;
&lt;P&gt;buildings = arcpy.SearchCursor("building_clip")&lt;/P&gt;
&lt;P&gt;parc_field = "parcels_ASSESSOR_N_1"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for building in buildings:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get Parcel Number of building&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; building_ID = building.getValue(parc_field)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Create search cursor for looping through the buildings&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sewers = arcpy.SearchCursor(DestinationTable)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sewer_field = "parcel_id"&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for sewer in sewers:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Get parc of sewer&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sewer_parc = sewer.getValue(sewer_field)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query = "parcel_id = " + "'%s'" %building_ID&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print query&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(DestinationTable, "ADD_TO_SELECTION", query)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; #&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break&lt;/P&gt;
&lt;P&gt;del buildings, sewers&lt;/P&gt;
&lt;/PRE&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14146901829708304" jivemacro_uid="_14146901829708304" modifiedtitle="true"&gt;
&lt;P&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 17:33:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338112#M26540</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2014-10-30T17:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: Python and Relates</title>
      <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338113#M26541</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using ArcGIS 10.1 or greater?&amp;nbsp; If so, I encourage you to give the cursors in the &lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018w00000008000000"&gt;arcpy data access (arcpy.da) module&lt;/A&gt; a try.&amp;nbsp; The data access cursors are more robust and may not crash as easily.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 18:01:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338113#M26541</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2014-10-30T18:01:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python and Relates</title>
      <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338114#M26542</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We do...we are running 10.2.1.&amp;nbsp; I will check that out!&amp;nbsp; Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 18:31:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338114#M26542</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2014-10-30T18:31:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python and Relates</title>
      <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338115#M26543</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Also, there is some good information on this topic in StackExchange:&amp;nbsp; &lt;A href="http://gis.stackexchange.com/questions/50287/how-can-i-more-efficiently-select-related-records"&gt;How can I more efficiently select related records?&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Oct 2014 18:45:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338115#M26543</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2014-10-30T18:45:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python and Relates</title>
      <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338116#M26544</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That worked like a charm --- and was about 100x faster processing!&amp;nbsp; Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 31 Oct 2014 23:22:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338116#M26544</guid>
      <dc:creator>CynthiaKozma</dc:creator>
      <dc:date>2014-10-31T23:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python and Relates</title>
      <link>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338117#M26545</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Glad it worked out for you.&amp;nbsp; I used that same discussion last year to sort through a similar issue, figured it better to point you there than repeat it all here.&amp;nbsp; Cheers.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 01 Nov 2014 15:07:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-and-relates/m-p/338117#M26545</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2014-11-01T15:07:39Z</dc:date>
    </item>
  </channel>
</rss>

