<?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: updateConnection Properties: Switching in and out of Feature Datasets in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/updateconnection-properties-switching-in-and-out/m-p/1373094#M69701</link>
    <description>&lt;P&gt;I don't want to jinx myself, but I dusted this script off today for the first time in months and this problem seems&amp;nbsp; to have been resolved since we upgraded to 3.1 from 2.9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good news for me, but I have questions now lol.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Jan 2024 18:33:24 GMT</pubDate>
    <dc:creator>AlfredBaldenweck</dc:creator>
    <dc:date>2024-01-22T18:33:24Z</dc:date>
    <item>
      <title>updateConnection Properties: Switching in and out of Feature Datasets</title>
      <link>https://community.esri.com/t5/python-questions/updateconnection-properties-switching-in-and-out/m-p/1285216#M67577</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I'm running into yet another issue with updateConnectionProperties()&lt;/P&gt;&lt;P&gt;I am trying to switch between example4gdb, which is in a feature dataset, and ex2gdb, which is not.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_0-1683126583574.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69755iF74DFF830D42AC87/image-size/medium?v=v2&amp;amp;px=400" role="button" title="AlfredBaldenweck_0-1683126583574.png" alt="AlfredBaldenweck_0-1683126583574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_1-1683127105724.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69756iF92CA6A11EC5E5D8/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_1-1683127105724.png" alt="AlfredBaldenweck_1-1683127105724.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;In this picture, ex2gdb is represented by red triangles with the number 2 in them. example4gdb is represented by green squares with the number 4 in them. The goal is to switch the layers so that ex2gdb displays as green squares and example4gdb draws as red triangles.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I'm struggling with getting it to work correctly.&lt;/P&gt;&lt;P&gt;My most successful approach has been to create a feature layer and copy the connection properties from it onto the layer I'm trying to update.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;sourceDict = {r"...test.gdb\testFD\example4gdb" : r"...test.gdb\ex2gdb",
              r"...test.gdb\ex2gdb": r"....test.gdb\testFD\example4gdb"}

for lay in layerFile.listLayers():
    if lay.supports("dataSource"):
        layPath = lay.dataSource
    else:
        layPath= arcpy.da.Describe(lay)["catalogPath"]

    if layPath in sourceDict:
        tempLay = arcpy.management.MakeFeatureLayer(sourceDict[layPath], "tempLay")[0]
        layCP = lay.connectionProperties
        fCP = tempLay.connectionProperties
        lay.updateConnectionProperties(layCP, fCP )&lt;/LI-CODE&gt;&lt;P&gt;This has the desired effect visually:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AlfredBaldenweck_2-1683127292607.png" style="width: 999px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/69758i55AAA1E8804287D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="AlfredBaldenweck_2-1683127292607.png" alt="AlfredBaldenweck_2-1683127292607.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;However, it doesn't correctly update the actual datasource; the datasources become the following, which very much do not exist:&lt;/P&gt;&lt;PRE&gt;&amp;nbsp;"...test.gdb\testFD\ex2gdb"&lt;BR /&gt;&lt;BR /&gt;"...test.gdb\example4gdb"&lt;/PRE&gt;&lt;P&gt;Consequently, I can't do any other geoprocessing with these layers because the files they reference are not real.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How can I cleanly update connection properties without running into this problem?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 15:34:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updateconnection-properties-switching-in-and-out/m-p/1285216#M67577</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2023-05-03T15:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: updateConnection Properties: Switching in and out of Feature Datasets</title>
      <link>https://community.esri.com/t5/python-questions/updateconnection-properties-switching-in-and-out/m-p/1373094#M69701</link>
      <description>&lt;P&gt;I don't want to jinx myself, but I dusted this script off today for the first time in months and this problem seems&amp;nbsp; to have been resolved since we upgraded to 3.1 from 2.9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good news for me, but I have questions now lol.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 18:33:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/updateconnection-properties-switching-in-and-out/m-p/1373094#M69701</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-01-22T18:33:24Z</dc:date>
    </item>
  </channel>
</rss>

