<?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: AttributeError: LayerObject: Get attribute dataSource does not exist in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318034#M1044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: jvondracek&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the ArcGIS 10 Help for the &lt;/SPAN&gt;&lt;STRONG&gt;dataSource &lt;/STRONG&gt;&lt;SPAN&gt;property:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]Returns the complete path for the layer's data source. It includes the workspacePath and the datasetName properties combined. Not all layers support the dataSource property (for example, annotation classes, Web services), so it is good practice to test for this ahead of time using the supports method.[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if you have any group layers or whatever in your MXD, such layer will not have a dataSource property but your code assumes that it does.&amp;nbsp; In your for loop before you test to see if the dataSource for the current layer is the "old datasource", you might want to check to see whether the current layer is one that supports this property before you attempt to access it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 21 Dec 2010 14:45:53 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2010-12-21T14:45:53Z</dc:date>
    <item>
      <title>AttributeError: LayerObject: Get attribute dataSource does not exist</title>
      <link>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318033#M1043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to get this script to loop thru a directory and change the datasources of specific feature classes in all mxds. I've been successful with the replaceworkspaces method, but am hitting a wall with the replacedatasources method.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have posted 2 scripts....The BatchReplaceWorkspaces_tool.py is a bit rough but works well. It will go thru folders and subfolders changing specified workspaces. It saves maps back to 9.3 and mirrors the source directory structure.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attempted a similar tact with the replacedatasources method in the BatchReplaceDataSources_tool.py script, but to no avail.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am recieving the following error with the latter script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:/scripts/Python/Testing/BatchReplaceDataSources_tool.py", line 28, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.dataSource == OldDS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\_base.py", line 70, in _get&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return convertArcObjectToPythonObject(getattr(self._arc_object, attr_name))&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: LayerObject: Get attribute dataSource does not exist&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Wanted to see if anyone sees anything I don't.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 22:07:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318033#M1043</guid>
      <dc:creator>JamesGustine</dc:creator>
      <dc:date>2010-12-20T22:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: LayerObject: Get attribute dataSource does not exist</title>
      <link>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318034#M1044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: jvondracek&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;According to the ArcGIS 10 Help for the &lt;/SPAN&gt;&lt;STRONG&gt;dataSource &lt;/STRONG&gt;&lt;SPAN&gt;property:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[INDENT]Returns the complete path for the layer's data source. It includes the workspacePath and the datasetName properties combined. Not all layers support the dataSource property (for example, annotation classes, Web services), so it is good practice to test for this ahead of time using the supports method.[/INDENT]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, if you have any group layers or whatever in your MXD, such layer will not have a dataSource property but your code assumes that it does.&amp;nbsp; In your for loop before you test to see if the dataSource for the current layer is the "old datasource", you might want to check to see whether the current layer is one that supports this property before you attempt to access it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Dec 2010 14:45:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318034#M1044</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2010-12-21T14:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: LayerObject: Get attribute dataSource does not exist</title>
      <link>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318035#M1045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Nice, that fixed the error. I also had the feature dataset included in the new workspace string variable. Which is not neccesary. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks alot- James&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 21 Dec 2010 15:25:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318035#M1045</guid>
      <dc:creator>JamesGustine</dc:creator>
      <dc:date>2010-12-21T15:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: LayerObject: Get attribute dataSource does not exist</title>
      <link>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318036#M1046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding to Geonet Admin's answer, I used&lt;A href="https://docs.python.org/2/library/functions.html#hasattr" rel="nofollow noopener noreferrer" target="_blank"&gt; hasattr(class, 'prop')&lt;/A&gt; to check each incoming layer had the datasource property.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&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;&amp;nbsp; 
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;for df in arcpy.mapping.ListDataFrames(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; brknList = arcpy.mapping.ListBrokenDataSources(mxd)&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;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for bk in brknList:&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;&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; &lt;STRONG&gt;if hasattr(bk, "dataSource"):&amp;nbsp;&amp;nbsp; &lt;/STRONG&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;&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;&amp;nbsp; bk_list.append(bk.dataSource)&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 15:07:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318036#M1046</guid>
      <dc:creator>KenGalliher1</dc:creator>
      <dc:date>2021-12-11T15:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: AttributeError: LayerObject: Get attribute dataSource does not exist</title>
      <link>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318037#M1047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes.&amp;nbsp; Good catch.&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 16:58:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/attributeerror-layerobject-get-attribute/m-p/318037#M1047</guid>
      <dc:creator>KenGalliher1</dc:creator>
      <dc:date>2015-03-16T16:58:56Z</dc:date>
    </item>
  </channel>
</rss>

