Skip to content

Instantly share code, notes, and snippets.

@M-Bryant
Last active August 29, 2015 14:08
Show Gist options
  • Save M-Bryant/74719b852dea1f1f70cb to your computer and use it in GitHub Desktop.
Save M-Bryant/74719b852dea1f1f70cb to your computer and use it in GitHub Desktop.
arcpy: checks if ArcMap layer is a CAD layer
def isCADLayer(layer):
''' Returns True if a layer is a CAD layer.
'''
desc = arcpy.Describe(layer)
if hasattr(desc, "dataType") and (desc.dataType == "FeatureLayer"):
describeTable = arcpy.Describe(desc.catalogPath)
if describeTable.dataElementType == "DEFeatureClass":
describePath = arcpy.Describe(describeTable.path)
if hasattr(describePath, "dataType")
and (describePath.dataType == "CadDrawingDataset"):
return True
return False
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd)[0]
print isCadLayer(lyr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment