<?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: replaceDataSource OR findAndReplaceWorkspacePath for CAD files in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213858#M16481</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello DrColgate and Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering if there were any solutions yet. I'm having the same issue (with 10.0 SP4).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This line works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;lyr.replaceDataSource("X:\\SiteA\\MappingData", "CAD_WORKSPACE", "Polyline")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However since there is no refference to a specific CAD file, it will connect to the first CAD file it finds in that directory (there are multiple CAD files in the directory, and I don't want the first one).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The line of code that would be perfect is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;lyr.replaceDataSource("X:\\SiteA\\MappingData\\Sheet3.dwg", "CAD_WORKSPACE", "Polyline")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, this produces the error: "ValueError: Layer: Unexpected error"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried many variations of line above, but can't seem to get it to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas? Could this be a bug?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;~Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 18 May 2012 13:10:49 GMT</pubDate>
    <dc:creator>JoshuaChisholm</dc:creator>
    <dc:date>2012-05-18T13:10:49Z</dc:date>
    <item>
      <title>replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213852#M16475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've been trying to update the links to CAD that have had their name changed and have been moved to a different location but have had no changes made to the data itself.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Essentially the Original Path and the New Path are taken from an existing List and the data is updated as either:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer.replaceDataSource(unicode(DATA_PATH), FILE_TYPE, unicode(FILE_NAME))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;OR&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer.findAndReplaceWorkspacePath(unicode(PREV_PATH), unicode(DATA_PATH))
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Either way I get the same error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&amp;lt;type 'exceptions.ValueError'&amp;gt;: Layer: Unexpected error&lt;BR /&gt;Failed to execute (BatchMxdDataSourceUpdate).&lt;/BLOCKQUOTE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Where "BatchMxdDataSourceUpdate" is the routine that I am running to update that MXD data sources.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using the same code to loop through and update from SHP to GDB, GDB to GDB and also replacing Raster so I am not sure why it is not working for CAD files.&amp;nbsp; Each has a different handler but is essentially the same syntax.&amp;nbsp; In this case the CAD files are DXF but I have other instances of DWG that will also need to be updated in the future.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213852#M16475</guid>
      <dc:creator>HenryColgate</dc:creator>
      <dc:date>2021-12-11T10:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213853#M16476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'll do some testing with CAD files.&amp;nbsp; In the meantime, have you tried&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;MXD.findAndReplaceWorkspacePaths?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Dec 2011 14:18:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213853#M16476</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2011-12-29T14:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213854#M16477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tested several scenarios using DXF and DWG.&amp;nbsp; I reproduced the error once until I realized the mistake.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1) CAD layers are often group layers but you can't change a data source on a group layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) Make sure you get the name correct.&amp;nbsp; The default layer name is not the same as the feature class name.&amp;nbsp; For example, the layer name may be "buildings.dxf Point".&amp;nbsp; You must use "Point" as the dataset_name value, not the whole string.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are the tests that I did:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Temp\CAD.mxd")

'''CAD files are being remapped from a folder called Drive_A to a
folder called Drive_B.&amp;nbsp; Also, in the MXD, I renamed the layers to
represent only the feature class name in the CAD file.'''

#Test #1
mxd.findAndReplaceWorkspacePaths("Drive_A", "Drive_B")
mxd.saveACopy(r"C:\Temp\CAD_Test1.mxd")
del mxd

#Test #2
mxd = arcpy.mapping.MapDocument(r"C:\Temp\CAD.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp; lyr.findAndReplaceWorkspacePath("Drive_A", "Drive_B")
mxd.saveACopy(r"C:\Temp\CAD_Test2.mxd")
del mxd

#Test #3
mxd = arcpy.mapping.MapDocument(r"C:\Temp\CAD.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp; if lyr.isGroupLayer == False:
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.replaceDataSource(r"C:\Active\ArcPY\ScrumWorks\Data\Drive_B",
&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; "CAD_WORKSPACE", lyr.name)
mxd.saveACopy(r"C:\Temp\CAD_Test3.mxd")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213854#M16477</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T10:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213855#M16478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have had a look at your code and I am still not able to figure out where I am going wrong but I am hoping if I explain what I am doing a little more clearly it will help you help me =D&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a CSV file from which I am reading four columns of which I will give an example below:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ORIGINAL_NAME_COLUMN: "Polyline"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ORIGINAL_PATH_COLUMN: "C:\CAD_Directory\CAD_File.dxf"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NEW_NAME_COLUMN:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "Polyline"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NEW_PATH_COLUMN:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "X:\New_CAD_Directory\CAD_File_1.dxf"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it is important to note that I have changed the name of the CAD file which may be where I am falling down.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For each layer to get rid of group layers etc I run: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if layer.supports("DATASOURCE") and layer.supports("WORKSPACEPATH"):
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then I loop through the rows in the CSV and compare it to the layer data source using the following code&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if os.path.join(row[1], row[0]) == layer.dataSource:
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;which is equivalent to something like&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if "C:\CAD_Directory\CAD_File.dxf\Polyline" == layer.dataSource:
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If this succeeds I attempt to change the data source.&amp;nbsp; As the Data Source in 'layer.DataSource' goes to the full DXF path then I have assumed this would be the code for the 'ReplaceDataSource'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Now from your code I understand that you are pointing to a directory rather than the DXF as the data source.&amp;nbsp; To continue using my example above &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your code would be similar to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer.replaceDataSource(r"X:\New_CAD_Directory", "CAD_WORKSPACE", layer.name)

OR

layer.findAndReplaceWorkspace(r"C:\CAD_Directory", r"X:\New_CAD_Directory")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Where as my code looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer.replaceDataSource(r"X:\New_CAD_Directory\CAD_File_1.dxf", "CAD_WORKSPACE", layer.name)

OR

layer.findAndReplaceWorkspace(r"C:\CAD_Directory\CAD_File.dxf", r"X:\New_CAD_Directory\CAD_File_1.dxf")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the Data Source is only to the directory level then I am uncertain as to how to map to a new DXF name.&amp;nbsp; Particularly if there are several CAD files in there as I would assume that it automatically use the original CAD file name if pointing to a directory.&amp;nbsp; If the Data Source goes to the DXF level then I don't know why it is falling over.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213855#M16478</guid>
      <dc:creator>HenryColgate</dc:creator>
      <dc:date>2021-12-11T10:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213856#M16479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If the dataset name is different you must use lyr.replaceDataSource()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A dataSource = workspace_path + dataset_name&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The syntax is &lt;/SPAN&gt;&lt;STRONG&gt;lyr.replaceDataSource(workspace_path, workspace_type, &lt;STRONG&gt;dataset_name&lt;/STRONG&gt;, {validate})&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are setting the workspace_path=the entire dataSource.&amp;nbsp; No, break it&amp;nbsp; up and specify the workspacePath and datasetName as two separate parameters.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So your code should be something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;layer.replaceDataSource(row[1], "CAD_WORKSPACE", row[0])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213856#M16479</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T10:29:29Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213857#M16480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Okay, I think I have it right.&amp;nbsp; But unfortunately it is still failing so I must be doing someting wrong.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have used exactly your code but replaced the old column numbers with the new ones ie 1 = 3, 0 = 2.&amp;nbsp; Which is what I think you were referring to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer.replaceDataSource(row[2], "CAD_WORKSPACE", row[3])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This translates roughly to:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
layer.replaceDataSource("X:\New_CAD_Directory\CAD_File_1.dxf", "CAD_WORKSPACE", "Polyline")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have checked the new dataset for any access issues but it works in ArcMap/ArcCatalog.&amp;nbsp; The script is still failing with the same error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213857#M16480</guid>
      <dc:creator>HenryColgate</dc:creator>
      <dc:date>2021-12-11T10:29:32Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213858#M16481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello DrColgate and Jeff,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was wondering if there were any solutions yet. I'm having the same issue (with 10.0 SP4).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This line works:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;lyr.replaceDataSource("X:\\SiteA\\MappingData", "CAD_WORKSPACE", "Polyline")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However since there is no refference to a specific CAD file, it will connect to the first CAD file it finds in that directory (there are multiple CAD files in the directory, and I don't want the first one).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The line of code that would be perfect is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;lyr.replaceDataSource("X:\\SiteA\\MappingData\\Sheet3.dwg", "CAD_WORKSPACE", "Polyline")&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, this produces the error: "ValueError: Layer: Unexpected error"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried many variations of line above, but can't seem to get it to work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas? Could this be a bug?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;~Josh&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 18 May 2012 13:10:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213858#M16481</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2012-05-18T13:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213859#M16482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No solution as yet.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bug #NIM078454 &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The work around provided doesn't work so I wouldn't bother with that either.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 03 Feb 2013 23:49:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213859#M16482</guid>
      <dc:creator>HenryColgate</dc:creator>
      <dc:date>2013-02-03T23:49:21Z</dc:date>
    </item>
    <item>
      <title>Re: replaceDataSource OR findAndReplaceWorkspacePath for CAD files</title>
      <link>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213860#M16483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This issue was addressed with 10.1 SP1.&amp;nbsp; The same problem occured with changing data sources for Coverages.&amp;nbsp; The issue was that the feature class name was "Polygon" not CAD name\Polygon or Coverage Name \ Polygon.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here is some test code that is used to verify the fix.&amp;nbsp; Notice the dataset name parameter syntax.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, sys
relpath = os.path.dirname(sys.argv[0])
mxd = arcpy.mapping.MapDocument(relpath + "\\CoverageAndCAD_DataSources.mxd")
covLyr = arcpy.mapping.ListLayers(mxd)[0]
cadLyr = arcpy.mapping.ListLayers(mxd)[1]

covLyr.replaceDataSource(covLyr.workspacePath, "ARCINFO_WORKSPACE", "basin_utmcopy/Polygon")
if "utmcopy" in covLyr.dataSource:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "COVERAGE: PASSED"
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "COVERAGE: FAILED"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
cadLyr.replaceDataSource(cadLyr.workspacePath, "CAD_WORKSPACE", "ParcelsCopy.dwg/Polygon")
if "ParcelsCopy" in cadLyr.dataSource:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "CAD PASSED"
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "CAD: FAILED"
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please confirm that this helps you,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:29:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/replacedatasource-or-findandreplaceworkspacepath/m-p/213860#M16483</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T10:29:35Z</dc:date>
    </item>
  </channel>
</rss>

