Turn off Base Map Error

Discussion created by shaun_weston-eagle-co-nz-esridist on Apr 26, 2011
Latest reply on May 17, 2011 by trenthardy
I have a script as follows:
    dataFrame = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
    for lyr in arcpy.mapping.ListLayers(mxd):
        lyr.visible = False
    for lyr in arcpy.mapping.ListLayers(mxd, "Parcel Boundary", dataFrame):
        lyr.visible = True
    for lyr in arcpy.mapping.ListLayers(mxd, "Plan Features", dataFrame):
        lyr.visible = True    

When I run this I get the below error:
Traceback (most recent call last):
  File "E:\Current Projects\Kapiti Coast District Council\Scripts\", line 19, in <module>
    lyr.visible = False
  File "D:\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\", line 77, in _set
    return setattr(self._arc_object, attr_name, ao)
AttributeError: LayerObject: Error in accessing Visible property
LayerObject: Error in accessing Visible property

I don't really know what this means and it works fine when I have no base maps in my map document, but whenever I use this command lyr.visible = False on a basemap I get the above error and it works fine when I set it to true.

Does anyone know why I can't turn the visibility of a base map off with python?