Hi Jeff - many thanks for your time. Yep - I think I can work round the remove WMS bug using the top group layer that you suggested.Unfortunately, a can of worms has now opened! I've written a script to test for different types of layers in a given mxd to assist with general data management. However, I have two further queries that have come out of this:#1 (the main problem):I'm trying to identify different layers that support services, using the: lyr.supports("SERVICEPROPERTIES") property of the Layer class in the mapping module. It seems that I can identify WMS successfully, but I'm NOT able to test ArcGIS Server map services hosted on the arcgisonline servers. For example the World Imagery layer set fails the lyr.supports("SERVICEPROPERTIES") test. Please see below code. Also, as requested, please find the map package to mxd/data that I've been using: here#2:Regarding layers that are NOT Feature, Raster or Group Layers, such as CAD annotations, I've been trying to find a way to test what type of layers these are. I've resorted to the Describe class to test that the lyr.source is a 'FeatureClass' dataType. Then hook on to the featureType to expose what type of feature it is. In this case CAD annotations = "CoverageAnnotation". Basically, is this the best way to test Layers in mxd that support DATASOURCE, but are that are not Feature Layers ?Hope this is all clear from the code and the map package...many thanks for your help!import arcpy, os, string
mxdPTH = "c:\temp\example05_services.mxd"
mxd = arcpy.mapping.MapDocument(mxdPTH)
try:
#loop through data frames
for df in arcpy.mapping.ListDataFrames(mxd):
#get layers list & loop through
LyrList = arcpy.mapping.ListLayers(mxd, "", df)
for lyr in LyrList:
#test for group layer:
if lyr.isGroupLayer == True:
print "Group Layer Type: " + lyr.name
#test for raster layer:
elif lyr.isRasterLayer == True:
print "Raster Layer Type: " + lyr.name
#test for feature layer:
elif lyr.isFeatureLayer == True:
print "Feature Layer Type: Layer Name: " + lyr.name
#test for service layer:
elif lyr.supports("SERVICEPROPERTIES"):
print "Layer Supports 'SERVICEPROPERTIES': Service Type: " + lyr.serviceProperties["ServiceType"] + ": Layer Name: " + lyr.name
#test for non-Feature Layers that DO support DATASOURCE
elif lyr.supports("DATASOURCE"):
#invoke describe class
desc = arcpy.Describe(lyr.dataSource)
#test for FeatureClass Type
if desc.datasetType == "FeatureClass":
print "Non Feature-Layer Type: Using Describe Class: FeatureClass Type: " + str(desc.featureType) + ": Layer Name: " + lyr.name
else:
print "Non Feature-Layer Type: Using Describe Class: Non-FeatureClass Type: " + str(desc.datasetType) + lyr.name
#catch other layer types
else:
print "Other Layer Type: Layer Name: " + lyr.name
#get table list & loop
TabList = arcpy.mapping.ListTableViews(mxd, "", df)
for tab in TabList:
print "Table: " + tab.name
del mxd
del TabList
del LyrList
except Exception, e:
import traceback
map(arcpy.AddError, traceback.format_exc().split("\n"))
arcpy.AddError(str(e))
print "Exception: " + str(e)