<?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 Changing the data source of an annotation layer/joined table in ArcMap with Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/changing-the-data-source-of-an-annotation-layer/m-p/400956#M31563</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey everyone; since ESRI is forcing us to go with Direct Connects on SDE, I'm tasked with writing a script that repairs map documents so the layers are connected to their source via direct connection instead of a service connection. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I created a python script that uses the layer.replaceDataSource for each layer in the map. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if lyr.supports("SERVICEPROPERTIES"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; servProp = lyr.serviceProperties&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; serviceType = servProp.get('ServiceType', 'N/A')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if serviceType == "SDE" and servProp.get('Service', 'N/A') &amp;lt;&amp;gt; 'sde:sqlserver:SDESERVER':&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dbaseName = servProp.get('Database', 'N/A')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print dbaseName + ": Service=" + servProp.get('Service', 'N/A')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if dbaseName == "geo_data":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; lyr.replaceDataSource("J:\GIS\ArcMapResources\SDEConnectionFiles\LocalData.sde", "SDE_WORKSPACE", "Geo_Data.SDE." + lyr.name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The LocalData.sde file is the same connection file that people used originally to get the data for their maps. I just changed the connection type in the Connection Properties of this file to be a direct connection instead of a service connection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that database annotation layers don't respond to this method. Is there a method or tool that re-points connections for annotation layers?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, some of our layers are feature classes joined to SQL Server database tables or views. I can fix the data source of the feature class, but the joined table doesn't fix. Is there a way to use Python to fix that connection?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Richard&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 25 Nov 2013 15:43:38 GMT</pubDate>
    <dc:creator>RichardLesperance</dc:creator>
    <dc:date>2013-11-25T15:43:38Z</dc:date>
    <item>
      <title>Changing the data source of an annotation layer/joined table in ArcMap with Python</title>
      <link>https://community.esri.com/t5/python-questions/changing-the-data-source-of-an-annotation-layer/m-p/400956#M31563</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey everyone; since ESRI is forcing us to go with Direct Connects on SDE, I'm tasked with writing a script that repairs map documents so the layers are connected to their source via direct connection instead of a service connection. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So I created a python script that uses the layer.replaceDataSource for each layer in the map. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if lyr.supports("SERVICEPROPERTIES"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; servProp = lyr.serviceProperties&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; serviceType = servProp.get('ServiceType', 'N/A')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if serviceType == "SDE" and servProp.get('Service', 'N/A') &amp;lt;&amp;gt; 'sde:sqlserver:SDESERVER':&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; dbaseName = servProp.get('Database', 'N/A')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print dbaseName + ": Service=" + servProp.get('Service', 'N/A')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if dbaseName == "geo_data":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; lyr.replaceDataSource("J:\GIS\ArcMapResources\SDEConnectionFiles\LocalData.sde", "SDE_WORKSPACE", "Geo_Data.SDE." + lyr.name)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The LocalData.sde file is the same connection file that people used originally to get the data for their maps. I just changed the connection type in the Connection Properties of this file to be a direct connection instead of a service connection.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that database annotation layers don't respond to this method. Is there a method or tool that re-points connections for annotation layers?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, some of our layers are feature classes joined to SQL Server database tables or views. I can fix the data source of the feature class, but the joined table doesn't fix. Is there a way to use Python to fix that connection?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Richard&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Nov 2013 15:43:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/changing-the-data-source-of-an-annotation-layer/m-p/400956#M31563</guid>
      <dc:creator>RichardLesperance</dc:creator>
      <dc:date>2013-11-25T15:43:38Z</dc:date>
    </item>
  </channel>
</rss>

