Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add an CAD Drawing Dataset into ArcMap using Python.

Question is how to add a Auto-CAD .dwg file to ArcMap using Python

Normally comes in as CAD file within a Group layer with: annotation, point, line, polygon, multipatch

this is the code I have so far

import os
import arcpy

#In reality the file path is not hard coded
filePath = "F:\2012\01001\ACAD\1201000AB_R1.dwg"

df=arcpy.mapping.ListDataFrames(mxd,"Project Area")[0]

groupLayer = arcpy.mapping.Layer(r"CAD")
targetGroupLayer = arcpy.mapping.ListLayers(mxd, "CAD", df)[0]
addLayer = arcpy.mapping.Layer(filePath)

#Have tried this too, plus escaping the \, and same error
#addLayer = arcpy.mapping.Layer(r"F:\2012\01001\ACAD\1201000AB_R1.dwg")
#arcpy.mapping.AddLayerToGroup(df, targetGroupLayer, addLayer, "BOTTOM")

UPDATE!!! I got it to work sort of by doing this

addLayer = arcpy.mapping.Layer(r"F:\\Jobs2012\\05665\\ACAD\\1205665WS_R1.dwg\\Annotation")

You have to explicitly name what part of the .dwg you want in this case the Annotation layer. What I need to do now is create a loop that adds 1205665WS_R1.dwg\wildcard to add all the layers at once.


I get the following Error

<type 'exceptions.ValueError'>: Object: CreateObject Layer invalid data source

Note: I have gotten this to work when adding a .shp file

These are some of the resources of have consulted thus far:

Add a new group layer with python ArcGIS 10

How do I add a shapefile in ArcGIS via python scripting?

How do you use folders as input/output parameters

Shape files are not being adding to MXD using arcPy

share|improve this question
I decided to leave this and not delete it since it took me some time to figure out that you have to explicitly call the .dwg. The whole I hope others don't suffer as I have suffered thing. – Tristan Forward Jun 20 '12 at 14:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.