Last active
August 29, 2015 14:08
-
-
Save M-Bryant/74719b852dea1f1f70cb to your computer and use it in GitHub Desktop.
arcpy: checks if ArcMap layer is a CAD layer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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