<?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 Programmatically change CAD Layer's data source in CAD/GIS Data Integration Questions</title>
    <link>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869621#M328</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to change the data source of a CAD layer in a Pro map using arcpy. Looking at the documentation on the arcpy.mp.Layer class I can see that the updateConnectionProperties method is the one to use. Get the connection properties dictionary from the existing layer, change what needs to be changed, and give the new connection properties to this method. But, the connectionProperties does not include the name of the drawing file, just the folder containing the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example: I have 2 layers in a Pro map from the Polyline layer of 2 different drawings, MyDrawing1.dwg and MyDrawing2.dwg in the same folder &lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; overflow-wrap: break-word; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;C:\CAD DataSources&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the connectionProperties for MyDrawing1.dwg/Polyline:&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[0].connectionProperties&lt;/P&gt;&lt;P&gt;{'dataset': 'Polyline', 'workspace_factory': 'Cad', 'connection_info': {'database': 'C:\\CAD DataSources'}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the connectionProperties for MyDrawing2.dwg/Polyline:&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[1].connectionProperties&lt;/P&gt;&lt;P&gt;{'dataset': 'Polyline', 'workspace_factory': 'Cad', 'connection_info': {'database': 'C:\\CAD DataSources'}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They are exactly the same, so my_layer.updateConnectionProperties(current_connection_info, new_connection_info) does nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dataSource property reflects the dwg file name, but I don't see how that property plays in the updateConnectionProperties method, and that property is read-only.&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[0].dataSource&lt;/P&gt;&lt;P&gt;'C:\\CAD DataSources\\MyDrawing1.dwg\\Polyline'&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[1].dataSource&lt;/P&gt;&lt;P&gt;'C:\\CAD DataSources\\MyDrawing2.dwg\\Polyline'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the Set Data Sources GUI correctly reassigns the layer's data source.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 Feb 2020 15:14:48 GMT</pubDate>
    <dc:creator>TedChapin</dc:creator>
    <dc:date>2020-02-07T15:14:48Z</dc:date>
    <item>
      <title>Programmatically change CAD Layer's data source</title>
      <link>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869621#M328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to change the data source of a CAD layer in a Pro map using arcpy. Looking at the documentation on the arcpy.mp.Layer class I can see that the updateConnectionProperties method is the one to use. Get the connection properties dictionary from the existing layer, change what needs to be changed, and give the new connection properties to this method. But, the connectionProperties does not include the name of the drawing file, just the folder containing the file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an example: I have 2 layers in a Pro map from the Polyline layer of 2 different drawings, MyDrawing1.dwg and MyDrawing2.dwg in the same folder &lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #3d3d3d; font-family: Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; overflow-wrap: break-word; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;C:\CAD DataSources&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the connectionProperties for MyDrawing1.dwg/Polyline:&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[0].connectionProperties&lt;/P&gt;&lt;P&gt;{'dataset': 'Polyline', 'workspace_factory': 'Cad', 'connection_info': {'database': 'C:\\CAD DataSources'}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here are the connectionProperties for MyDrawing2.dwg/Polyline:&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[1].connectionProperties&lt;/P&gt;&lt;P&gt;{'dataset': 'Polyline', 'workspace_factory': 'Cad', 'connection_info': {'database': 'C:\\CAD DataSources'}}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They are exactly the same, so my_layer.updateConnectionProperties(current_connection_info, new_connection_info) does nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The dataSource property reflects the dwg file name, but I don't see how that property plays in the updateConnectionProperties method, and that property is read-only.&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[0].dataSource&lt;/P&gt;&lt;P&gt;'C:\\CAD DataSources\\MyDrawing1.dwg\\Polyline'&lt;/P&gt;&lt;P&gt;arcpy.mp.ArcGISProject("CURRENT").activeMap.listLayers()[1].dataSource&lt;/P&gt;&lt;P&gt;'C:\\CAD DataSources\\MyDrawing2.dwg\\Polyline'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Using the Set Data Sources GUI correctly reassigns the layer's data source.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2020 15:14:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869621#M328</guid>
      <dc:creator>TedChapin</dc:creator>
      <dc:date>2020-02-07T15:14:48Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically change CAD Layer's data source</title>
      <link>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869622#M329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Ted,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a great question and I wonder the answer too. You might have better luck moving this post to the &lt;A href="https://community.esri.com/space/2145"&gt;Python&lt;/A&gt;‌ space so the Python experts can chime in.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Feb 2020 21:18:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869622#M329</guid>
      <dc:creator>AdrianWelsh</dc:creator>
      <dc:date>2020-02-07T21:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Programmatically change CAD Layer's data source</title>
      <link>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869623#M330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The answer is to use the CIM definition of the layer instead of the updateConnectionProperties method. If you notice in the layer properties dialog box, the drawing filename is stored in the "Feature Dataset" property. You can use the CIM to change this property. Here's the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;cad_layer = my_map.listLayers("My CAD Layer")[0]&lt;BR /&gt;cad_layer_cim = cad_layer.getDefinition("V2")&lt;BR /&gt;cad_layer_cim.featureTable.dataConnection.featureDataset = new_dwg_file_name&lt;BR /&gt;cad_layer.setDefinition(cad_layer_cim)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Feb 2020 21:08:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/cad-gis-data-integration-questions/programmatically-change-cad-layer-s-data-source/m-p/869623#M330</guid>
      <dc:creator>TedChapin</dc:creator>
      <dc:date>2020-02-11T21:08:04Z</dc:date>
    </item>
  </channel>
</rss>

