<?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 Export to CAD in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/export-to-cad/m-p/317062#M24652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm fairly new to programming in python so please bear with me.&amp;nbsp; I'm trying to create a script that loops through all the layers in my TOC and exports them to a CAd file. As first I tried ListFeatureClasses but this lists the whole feature class name e.g. shape.shp, which produces an error&amp;nbsp; as it tries to export shape.shpdxf&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I then tried ListLayers but get an error 000840 the value is not a CAD drawing dataset. Any Ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:\data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layers = arcpy.mapping.ListLayers(mxd)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.ExportCAD_conversion(lyr,"DWG_R2007",lyr,"Ignore_Filenames_in_Tables","Overwrite_Existing_Files")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Claire&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 Jul 2011 13:09:25 GMT</pubDate>
    <dc:creator>ClaireParsons</dc:creator>
    <dc:date>2011-07-11T13:09:25Z</dc:date>
    <item>
      <title>Export to CAD</title>
      <link>https://community.esri.com/t5/python-questions/export-to-cad/m-p/317062#M24652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm fairly new to programming in python so please bear with me.&amp;nbsp; I'm trying to create a script that loops through all the layers in my TOC and exports them to a CAd file. As first I tried ListFeatureClasses but this lists the whole feature class name e.g. shape.shp, which produces an error&amp;nbsp; as it tries to export shape.shpdxf&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So I then tried ListLayers but get an error 000840 the value is not a CAD drawing dataset. Any Ideas?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:\data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;layers = arcpy.mapping.ListLayers(mxd)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print(lyr)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.ExportCAD_conversion(lyr,"DWG_R2007",lyr,"Ignore_Filenames_in_Tables","Overwrite_Existing_Files")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Claire&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 13:09:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-cad/m-p/317062#M24652</guid>
      <dc:creator>ClaireParsons</dc:creator>
      <dc:date>2011-07-11T13:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Export to CAD</title>
      <link>https://community.esri.com/t5/python-questions/export-to-cad/m-p/317063#M24653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well, I'm quite pleased with myself as I've managed to sort the problem &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've used ListFeatureClasses to create a list and then 'rstrip(".shp")' to take shp from the end then added '.dwg'.&amp;nbsp; See below.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import os&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#Set the workspace&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;env.workspace = "C:/data"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fclist = arcpy.ListFeatureClasses()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;outputloc = "C:/data/"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;fextension = ".dwg"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for fc in fclist:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; arcpy.ExportCAD_conversion(fc,"DXF_R2007",outputloc + fc.rstrip(".shp") + fextension,"Use_Filenames_in_Tables","Overwrite_Existing_Files")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe this means I am on the way to understanding Python!!! :eek:&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 Jul 2011 16:14:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/export-to-cad/m-p/317063#M24653</guid>
      <dc:creator>ClaireParsons</dc:creator>
      <dc:date>2011-07-11T16:14:17Z</dc:date>
    </item>
  </channel>
</rss>

