<?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: ArcPy CAD Layers Iteration to GeoDataBase in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224620#M17337</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That looks better.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should read the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000014000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Docs for ListDatasets&lt;/A&gt;&lt;SPAN&gt;. You are calling it with this: &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;arcpy.ListDatasets("*.dwg", "CAD")&lt;/SPAN&gt;&lt;SPAN&gt;, but "CAD" is not a valid feature type for this tool, so it returns a value of &lt;/SPAN&gt;&lt;STRONG&gt;None&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can tell that something is fishy because of this in your test:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; print '1: ', arcpy.ListDatasets("*.dwg", "CAD")
1: None&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That means your next line, &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;for fd in arcpy.ListDatasets("*.dwg", "CAD"):&lt;/SPAN&gt;&lt;SPAN&gt; is actually being evaluated as &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;for fd in None:&lt;/SPAN&gt;&lt;SPAN&gt;, which doesn't make sense, so it causes an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope it is clear to you what is actually going on here...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To fix it, you can try the code below. I have just removed the "CAD" part in the ListDatasets, it will default to listing all files with a .dwg extension.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Name: ImportCADandMerge.py
# Description: Imports and merges polylines from one workspace into a single feature class

# Import system modules
import arcpy 
from arcpy import env

env.workspace = "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups"

# Create a value table that will hold the input feature classes for Merge
vTab = arcpy.ValueTable()

print '1: ', arcpy.ListDatasets("*.dwg")

# Step through each dataset in the list
for fd in arcpy.ListDatasets("*.dwg"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '2: ', fd
&amp;nbsp;&amp;nbsp;&amp;nbsp; layername = fd + "_Layer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select only the Polyine features on the drawing layer EX-PAVE
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fd + "/Polyline", layername, "\"Layer\" = 'EX-PAVE'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '3: ', layername
&amp;nbsp;&amp;nbsp;&amp;nbsp; vTab.addRow(layername)

# Merge the CAD features into one feature class
arcpy.Merge_management(vTab, "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups\VEDO_2014_Drawings.gdb")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 10:56:24 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2021-12-11T10:56:24Z</dc:date>
    <item>
      <title>ArcPy CAD Layers Iteration to GeoDataBase</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224617#M17334</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to extract an Ex-Pave layer out of a whole years worth of CAD drawings and I cannot seem to get the code to work&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I was able to find the following yet have not had an success. If anyone could shed some light on the error listed below it would be greatly appreciated. Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; Name: ImportCADandMerge.py
# Description: Imports and merges polylines from one workspace into a single feature class

# Import system modules
import arcpy 
from arcpy import env

env.workspace = "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups"

# Create a value table that will hold the input feature classes for Merge
vTab = arcpy.ValueTable()

# Step through each dataset in the list
for fd in arcpy.ListDatasets("*.dwg", "CAD"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; layername = fd + "_Layer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select only the Polyine features on the drawing layer EX-PAVE
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fd + "/Polyline", layername, "\"Layer\" = 'EX-PAVE'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; vTab.addRow(layername)

# Merge the CAD features into one feature class
arcpy.Merge_management(vTab, "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups\VEDO_2014_Drawings.gdb")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;File "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 322, in RunScript
&amp;nbsp;&amp;nbsp;&amp;nbsp; debugger.run(codeObject, __main__.__dict__, start_stepping=0)
&amp;nbsp; File "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\pywin\debugger\__init__.py", line 60, in run
&amp;nbsp;&amp;nbsp;&amp;nbsp; _GetCurrentDebugger().run(cmd, globals,locals, start_stepping)
&amp;nbsp; File "C:\Python27\ArcGIS10.1\Lib\site-packages\pythonwin\pywin\debugger\debugger.py", line 655, in run
&amp;nbsp;&amp;nbsp;&amp;nbsp; exec cmd in globals, locals
&amp;nbsp; File "C:\Student\PythEveryone10_1\CreatingScripts\CADtoLayer.txt", line 5, in &amp;lt;module&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy
TypeError: 'NoneType' object is not iterable&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 21:51:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224617#M17334</guid>
      <dc:creator>JeffJudycki</dc:creator>
      <dc:date>2013-08-07T21:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy CAD Layers Iteration to GeoDataBase</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224618#M17335</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jeff, how are you running this? Most of the traceback refers to PythonWin debugger, and the last part shows the file "C:\Student\PythEveryone10_1\CreatingScripts\CADtoLayer.txt" as causing some problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you run it directly from the command line? This will eliminate some of the confusion. &lt;/SPAN&gt;&lt;A href="http://pythongisandstuff.wordpress.com/2013/07/10/locating-python-adding-to-path-and-accessing-arcpy/" rel="nofollow noopener noreferrer" target="_blank"&gt;Here&lt;/A&gt;&lt;SPAN&gt; are instructions on finding your Arcpy Python install and calling it from the command line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would also recommend taking a step back and testing your code with lots of print statements i.e.:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Name: ImportCADandMerge.py
# Description: Imports and merges polylines from one workspace into a single feature class

# Import system modules
import arcpy 
from arcpy import env

env.workspace = "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups"

# Create a value table that will hold the input feature classes for Merge
vTab = arcpy.ValueTable()

print '1: ', arcpy.ListDatasets("*.dwg", "CAD")

# Step through each dataset in the list
for fd in arcpy.ListDatasets("*.dwg", "CAD"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '2: ', fd
&amp;nbsp;&amp;nbsp;&amp;nbsp; layername = fd + "_Layer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select only the Polyine features on the drawing layer EX-PAVE
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fd + "/Polyline", layername, "\"Layer\" = 'EX-PAVE'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '3: ', layername
&amp;nbsp;&amp;nbsp;&amp;nbsp; vTab.addRow(layername)

# Merge the CAD features into one feature class
arcpy.Merge_management(vTab, "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups\VEDO_2014_Drawings.gdb")
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will let you check each part. If the first statement prints &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;1: None&lt;/SPAN&gt;&lt;SPAN&gt;, then there are possibly no *.dwg files in the specified workspace.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:56:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224618#M17335</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T10:56:21Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy CAD Layers Iteration to GeoDataBase</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224619#M17336</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I was able to run the python script from the command line yet I am still getting similar error 'NoneType' object is not iterable? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideas&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; [ATTACH=CONFIG]26578[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And thank you for your help&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 08 Aug 2013 13:30:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224619#M17336</guid>
      <dc:creator>JeffJudycki</dc:creator>
      <dc:date>2013-08-08T13:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy CAD Layers Iteration to GeoDataBase</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224620#M17337</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That looks better.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You should read the &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000014000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Docs for ListDatasets&lt;/A&gt;&lt;SPAN&gt;. You are calling it with this: &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;arcpy.ListDatasets("*.dwg", "CAD")&lt;/SPAN&gt;&lt;SPAN&gt;, but "CAD" is not a valid feature type for this tool, so it returns a value of &lt;/SPAN&gt;&lt;STRONG&gt;None&lt;/STRONG&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can tell that something is fishy because of this in your test:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;gt;&amp;gt;&amp;gt; print '1: ', arcpy.ListDatasets("*.dwg", "CAD")
1: None&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That means your next line, &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;for fd in arcpy.ListDatasets("*.dwg", "CAD"):&lt;/SPAN&gt;&lt;SPAN&gt; is actually being evaluated as &lt;/SPAN&gt;&lt;SPAN style="font-family:Courier New;"&gt;for fd in None:&lt;/SPAN&gt;&lt;SPAN&gt;, which doesn't make sense, so it causes an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope it is clear to you what is actually going on here...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To fix it, you can try the code below. I have just removed the "CAD" part in the ListDatasets, it will default to listing all files with a .dwg extension.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;# Name: ImportCADandMerge.py
# Description: Imports and merges polylines from one workspace into a single feature class

# Import system modules
import arcpy 
from arcpy import env

env.workspace = "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups"

# Create a value table that will hold the input feature classes for Merge
vTab = arcpy.ValueTable()

print '1: ', arcpy.ListDatasets("*.dwg")

# Step through each dataset in the list
for fd in arcpy.ListDatasets("*.dwg"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '2: ', fd
&amp;nbsp;&amp;nbsp;&amp;nbsp; layername = fd + "_Layer"
&amp;nbsp;&amp;nbsp;&amp;nbsp; # Select only the Polyine features on the drawing layer EX-PAVE
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.MakeFeatureLayer_management(fd + "/Polyline", layername, "\"Layer\" = 'EX-PAVE'")
&amp;nbsp;&amp;nbsp;&amp;nbsp; print '3: ', layername
&amp;nbsp;&amp;nbsp;&amp;nbsp; vTab.addRow(layername)

# Merge the CAD features into one feature class
arcpy.Merge_management(vTab, "C:\Users\jjudycki\Desktop\Vectren\130103.00 - VEDO 2014 Groups\VEDO_2014_Drawings.gdb")&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:56:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-cad-layers-iteration-to-geodatabase/m-p/224620#M17337</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-11T10:56:24Z</dc:date>
    </item>
  </channel>
</rss>

