I am trying to find out if an mxd contains any schematic diagram layer through a python script tool. I am looping through all the mxds those are added to the python script tool and in each mxd checking each layer whether it's a schematicdiagram layer or not.
My actual code in .py file looks like this:
import arcpy
mxdList = string.split(arcpy.GetParameterAsText(0), ";")
outXLSpath = arcpy.GetParameterAsText(1)
mxdCount = 0
for mxdpath in mxdList:
if "'" in mxdpath:
mxdpath = mxdpath[1:-1]
else:
mxdpath = mxdpath
mxdCount = mxdCount + 1
mxd = arcpy.mapping.MapDocument(mxdpath)
(filepath,filename)= os.path.split(mxd.filePath)
arcpy.SetProgressorLabel("Extracting Layers for " + str(mxdCount) + " of " + str(len(mxdList)) + " MXDs \"" + filename[:-4] + "\"... ")
arcpy.AddMessage("Extracting Layers for " + filename + "..." )
lyrList = arcpy.mapping.ListLayers(mxd)
for lyr in lyrList:
if not lyr.isGroupLayer:
longNameList = lyr.longName.split("\\" or "//")
if len(longNameList)>1:
descTemp = arcpy.Describe('\\'.join(longNameList[:-1]))
if (not descTemp.dataType == "GroupLayer") and descTemp.dataElementType == "DESchematicDiagram":
arcpy.AddMessage("Schematic Layer")
The above code is throwing error for group layer it encounters in the list of layers. Following is the error being encountered by the tool!!
Traceback (most recent call last): File "C:\ANM\ArcGIS\Tools\MyTools\ExportLayerList3-1-Test.py", line 34, in <module>
descTemp = arcpy.Describe('\\'.join(longNameList[:-1]))
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\__init__.py", line 1234, in Describe
return gp.describe(value) File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 374, in describe
self._gp.Describe(*gp_fixargs(args, True)))
IOError: "Boundaries" does not exist Failed to execute (ExtractLayerList2)
.
surprisingly the same code is working fine if I test it in ArcMap's Python window.
Would someone highlight the issue and suggest the solution.
arcpy.GetParameterAsText(0)
etc?