In my MXD with 14 different Raster-Sets (12 Months(January, February...), 1 GRID, 1 Border-Raster) I am looking to create a list (Layer Objects) with the function
arcpy.mapping.ListLayers(mxd,"FILTER",df)[0].
I don't know how to specify a filter (Wildcard) to create a list containing only the 12 Months. So far I tried to filter the list monlist
with a tmplist
containing all the months as Strings.
In the following example, the line
monlist = arcpy.mapping.ListLayers(mxd, tmplist ,df)
does not work. In result I get an empty list monlist=[]
import arcpy
raster = arcpy.GetParameterAsText(0)
outPDF = arcpy.GetParameterAsText(1)
hill_bool = arcpy.GetParameterAsText(2)
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
hillshade = arcpy.mapping.ListLayers(mxd, "hillshade", df)[0]
hillshade.visible = hill_bool
tmplist = ["Januar","Februar","Maerz","April","April",
"Mai","Juni","Juli","August","September","Oktober","November","Dezember"]
monlist = arcpy.mapping.ListLayers(mxd, tmplist ,df) #Select only the months
addLayer = arcpy.mapping.Layer(r"C:Python\Legende_2.lyr")
arcpy.mapping.MoveLayer(df, monlist[:-1],hillshade, "AFTER")
for element in monlist:
element.visible = "TRUE"
arcpy.ApplySymbologyFromLayer_management("","addLayer")
if hillshade.visible = "TRUE": #<<< ???
element.transparency = 35
arcpy.RefreshActiveView()
...
#...align Legend and other objects -> ExportToPDF
arcpy.mapping.ExportToPDF(mxd, outPDF)