Okay, so I can feel that I am so close to solving this issue with the help of Jason (below) but I have modified to use as a script. The GetParameterAsText returns the following error when trying to execute:
: [Error 3] The system cannot find the path specified: u"'C:\Users\bob\Documents\folder\file.mxd';'C:\Users\folder\Documents\Folder\file.mxd';'C:\Users\folder\Documents\folder\file.mxd'\*.*"
Anyone know what is wrong with my code to keep getting this error?
import arcpy, os, string
#Read input/output folder path from script tool
folderPath = arcpy.GetParameterAsText(0)
outPNGfolder = arcpy.GetParameterAsText(1)
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
if os.path.isfile(fullpath):
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mxd = arcpy.mapping.MapDocument(fullpath)
arcpy.mapping.ExportToPNG(mxd, basename + '.png')
-
What is "mapping.PNGDcoumentCreate(outPNGpath)? This isn't a real mapping function. You don't need this line. You can download Pyscripter (free) and learn to debug your script.klewis– klewis2013年08月14日 13:37:25 +00:00Commented Aug 14, 2013 at 13:37
-
I was trying to modify an existing script that batch converts multiple map documents into a single PDF. I am new to all of this but couldn't find a simple solution to batch export multiple mxds into pngs thru model builder so I naturally migrated to python. I will look into pyscripter. Thank you.newbie123– newbie1232013年08月14日 14:46:12 +00:00Commented Aug 14, 2013 at 14:46
-
The ESRI online help has nice examples on how to use various arcpy.mapping functions & classes. help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//…klewis– klewis2013年08月14日 16:52:59 +00:00Commented Aug 14, 2013 at 16:52
-
What are you passing as your parameters? It should just be a single directory path.Tom– Tom2013年08月21日 17:10:16 +00:00Commented Aug 21, 2013 at 17:10
-
1@Tom - can you please make that an answer.Jakub Sisak GeoGraphics– Jakub Sisak GeoGraphics2013年10月08日 16:03:06 +00:00Commented Oct 8, 2013 at 16:03
1 Answer 1
From Jeff Moulds (ESRI) originally for pdf export here's some python you can customize. It works on all mxds in a folder so you could adjust that or perhaps copy the projects into one temporarily for exporting. I added paragraph spaces after the first 3 lines to make the text properly indent in the box below, not being smart enough to do that any other way.
import arcpy, os
folderPath = r"C:\Project"
for filename in os.listdir(folderPath):
fullpath = os.path.join(folderPath, filename)
if os.path.isfile(fullpath):
basename, extension = os.path.splitext(fullpath)
if extension.lower() == ".mxd":
mxd = arcpy.mapping.MapDocument(fullpath)
arcpy.mapping.ExportToPNG(mxd, basename + '.png')