I tried your, kamkashem, proposed version. After importing "os", one error message disappeared :D. But the problem of over writing each output ("str(X)") with the next one is not solved yet. So, How can i accomplish that str(x) is something like Str(Xi) for i=1...80 Or even nicer i = name of group layer. Because the jpeg format is more sympathetic to me, i inspired me also from this thread: http://forums.arcgis.com/threads/63173-Problem-accessing-ModelBuilder-variable-in-a-python-script (especially the record from 07-27-2012 08:40 PM ). my actual piece of code is the following: # ---------------------------------------------------------------------------
# map_production.py
#
# Description: "Should" generate jpg layout outputs of the input layernames
# ---------------------------------------------------------------------------
print "START map production"
print "arcpy and os importieren"
import arcpy
import os, sys, string, arcgisscripting
print "done arcpy and os and so on import"
gp = arcgisscripting.create(9.3)
scriptVar=gp.GetParameterAsText(0)
outfile = "test" + scriptVar +".jpg"
print "specify mxd"
#Specifies mxd
mxd = arcpy.mapping.MapDocument(r"H:/Desktop/Masterarbeit/test/Besprechung_Schmitten_Neu_6.mxd")
print "done mxd spezifizieren"
print "specify dataframe"
#Specifies dataframe of interest
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
print "done specify df "
#Turns all layers off
print "turn visibility of all layers off"
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
lyr.visible = False
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
print "visibility = False "
#Turns backgroundlayers on
print "turn backgroundlayer on: Visibility = true"
for lyr in arcpy.mapping.ListLayers(mxd, "hillshade*", df):
lyr.visible = True
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
print "background = visible"
print "start withE_95CI"
#Loops through the layers given in the quotas (eg. beginning with E_95CI) and creates a list of Layers:
for lyr in arcpy.mapping.ListLayers(mxd, "E_95CI", df):
print" produced list"
#For Each: Turn it on:
lyr.visible = True
print " visible: on"
arcpy.RefreshTOC()
print " TOC refreshed"
arcpy.RefreshActiveView()
print " Active View refreshed"
print "exporting for each layer starting with ""E_95CI"" a JPEG map within the folder map_export and the name construction ""outfile"" "
arcpy.mapping.ExportToJPEG(mxd, r"H://Desktop/map_export/" + outfile, df,df_export_width=1600, df_export_height=1200)
print "done_"
mxd.save()
print "done_ 20"
#Deletes the reference to the mxd from memory (not the actual mxd file)
del mxd
While it is possible to generate a the list E_95CI, the export to jpeg fails.The python Shell output looks like this: START map production
arcpy and os importieren
done arcpy and os and so on import
specify mxd
done mxd spezifizieren
specify dataframe
done specify df
turn visibility of all layers off
visibility = False
turn backgroundlayer on: Visibility = true
background = visible
start withE_95CI
produced list
visible: on
TOC refreshed
Active View refreshed
exporting for each layer starting with E_95CI a JPEG map within the folder map_export and the name construction outfile
Traceback (most recent call last):
File "H:\Desktop\Masterarbeit\Python scripts\test2.py", line 60, in <module>
arcpy.mapping.ExportToJPEG(mxd, r"H://Desktop/map_export/" + outfile, df,df_export_width=1600, df_export_height=1200)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\mapping.py", line 686, in ExportToJPEG
layout.exportToJPEG(*args)
AttributeError: DataFrameObject: Error in executing ExportToJPEG
Does anyone see a pissible solution? I am very happy to every answer!