<?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: Using arcpy.mapping, how to rename sde feature class in mxd files in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402665#M4418</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you please post what you get for the variable sdecon?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This needs to be a .sde file that you can find in ArcCatalog Add Spatial Database Connection.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 01 May 2013 15:09:48 GMT</pubDate>
    <dc:creator>MichaelVolz</dc:creator>
    <dc:date>2013-05-01T15:09:48Z</dc:date>
    <item>
      <title>Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402664#M4417</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have many mxd files by different users and I want to change one SDE feature class name in all those mxd files without changing SDE connections. As a test, I thought this script would work, but I always get "Unable to change name" exception. Where am I wrong?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"L:\users\guana\test_fc_rename.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for df in arcpy.mapping.ListDataFrames(mxd):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd,"",df):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.supports("DATASOURCE"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.dataSource.find("SDE_GOM.LEXCO_LEASE") &amp;lt;&amp;gt; -1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (str1,str2,fname) = lyr.dataSource.split("\\")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sdecon = str1 + "\\" + str2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "sdecon = " + sdecon&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(sdecon,"SDE_WORKSPACE","SDE_GOM.LEASE_LEXCO")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Unable to change name"&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 13:22:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402664#M4417</guid>
      <dc:creator>AllenGuan1</dc:creator>
      <dc:date>2013-05-01T13:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402665#M4418</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you please post what you get for the variable sdecon?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This needs to be a .sde file that you can find in ArcCatalog Add Spatial Database Connection.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2013 15:09:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402665#M4418</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-05-01T15:09:48Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402666#M4419</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Can you please post what you get for the variable sdecon?&lt;BR /&gt;&lt;BR /&gt;This needs to be a .sde file that you can find in ArcCatalog Add Spatial Database Connection.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;For this particular mxd file, the print is "sdecon = Database Connections\guana_npwd@usprd06.sde" (I also tried Database "sdecon=Connections\\guana_npwd@usprd06.sde"). But it can be very varied. Each user connects to sde DB using his own credential. Yes the documention says the first parameter for lyr.replaceDataSource should be a sde connection file, but I also saw an example somewhere that uses something like "Database Connections\user@sdedb.sde". We can not use a common connection file for all users. Should arcpy.mapping have a method that can rename a feature class without changing the workplace path?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Allen&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:34:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402666#M4419</guid>
      <dc:creator>AllenGuan1</dc:creator>
      <dc:date>2013-05-02T11:34:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402667#M4420</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you are using ArcGIS v10.1, I believe you need the full path to the connection file. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have "Database Connections\guana_npwd@usprd06.sde",&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where I have found at v10.1 you need something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;c:\Users\Roaming\guana_npwd@usprd06.sde (or wherever your SDE connection file is found)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 11:55:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402667#M4420</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-05-02T11:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402668#M4421</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you are using ArcGIS v10.1, I believe you need the full path to the connection file. &lt;BR /&gt;&lt;BR /&gt;You have "Database Connections\guana_npwd@usprd06.sde",&lt;BR /&gt;&lt;BR /&gt;where I have found at v10.1 you need something like:&lt;BR /&gt;&lt;BR /&gt;c:\Users\Roaming\guana_npwd@usprd06.sde (or wherever your SDE connection file is found)&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What I need is a simple function inside arcpy.mapping that can change a feature class name in mxd or layer file without having to touch the sde connection path or workspace path. I think arcpy.mapping totally misses this one. We can not use hundreds of sde connection files, each containing each user's sde credential, for batching processing. A single sde connection file only works for OS authentications, which we don't use.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 May 2013 19:25:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402668#M4421</guid>
      <dc:creator>AllenGuan1</dc:creator>
      <dc:date>2013-05-02T19:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402669#M4422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I would open a ticket with ESRI technical support at this point, as they may be able to point you to a simple function that change a feature class name in mxd or layer file besides the replaceDataSource method.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 11:52:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402669#M4422</guid>
      <dc:creator>MichaelVolz</dc:creator>
      <dc:date>2013-05-03T11:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402670#M4423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I would open a ticket with ESRI technical support at this point, as they may be able to point you to a simple function that change a feature class name in mxd or layer file besides the replaceDataSource method.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, will ask them. Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2013 11:56:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402670#M4423</guid>
      <dc:creator>AllenGuan1</dc:creator>
      <dc:date>2013-05-03T11:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using arcpy.mapping, how to rename sde feature class in mxd files</title>
      <link>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402671#M4424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You should search the mxd to find the layer for which you want to change the source&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;use ListLayers() &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The layer has a read only workspacePath property&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;which will be the connection file for an SDE layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Use that workspacePath in the &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;replaceDataSource(workspace_path, workspace_type, {dataset_name}, {validate})&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;method on the same layer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This way, the existing layer tells you what SDE connection file is currently used&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;and you just re-use it with a new feature class in the same database.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 24 Jul 2013 15:20:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/using-arcpy-mapping-how-to-rename-sde-feature/m-p/402671#M4424</guid>
      <dc:creator>markdenil</dc:creator>
      <dc:date>2013-07-24T15:20:31Z</dc:date>
    </item>
  </channel>
</rss>

