Found 5 mxds for PDF exporting... Directory: C:\Users\is0009\Desktop\temp Exporting Rural_OCP_map_1_17x11.mxd to: C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.pdf Traceback (most recent call last): File "<string>", line 70, in execInThread File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\netref.py", line 123, in __call__ File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\netref.py", line 45, in syncreq File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 343, in sync_request File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 305, in serve File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\protocol.py", line 265, in _recv File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\channel.py", line 36, in recv File "C:\Program Files (x86)\PyScripter\Lib\rpyc-python2x.zip\rpyc\core\stream.py", line 105, in read EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host
#Import python modules import os, sys, string, glob, arcpy from arcpy import mapping #Set local variables mxdLst = glob.glob('*.mxd') mxdCnt = len(mxdLst) #### #Place script in same folder as MXDs to get 'current working directory' #### baseF = os.getcwd() #Print how many mxd's found print '\n' + 'Found ' + str(mxdCnt) + ' mxds for PDF exporting...' print 'Directory: ' + str(baseF) + '\n' #Loop to process each mxd into a PDF for mxds in mxdLst: PDFr = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf' print 'Exporting ' + str(mxds) + ' to:' + '\n' + str(baseF) + '\\' + str(PDFr) #Print current mxd exporting and output pdf name... inMxd = arcpy.mapping.MapDocument(mxds) #Make current mxd in loop the mapdocument arcpy.mapping.ExportToPDF(inMxd, PDFr) #Export mapdocument to pdf print 'Done exporting: ' + str(PDFr) del mxds
#Import python modules import os, sys, string, glob, arcpy.mapping #Set local variables mxdLst = glob.glob('*.mxd') mxdCnt = len(mxdLst) #### #Place script in same folder as MXDs to get 'current working directory' #### baseF = os.getcwd() #Print how many mxd's found print '\n' + 'Found ' + str(mxdCnt) + ' MXDs for exporting to PDF...' print 'Directory: ' + baseF + '\n' #For loop to process each mxd into a PDF for mxds in mxdLst: #outPDF = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf' #print 'Exporting ' + mxds + ' -> ' + outPDF mxd = 'r' + '\"' + baseF + '\\' + mxds + '\"' #mxd with fullpathname #inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument #arcpy.mapping.ExportToPDF(inMxd, outPDF) #Export mapdocument to pdf #print 'Done exporting: ' + outPDF print mxd del mxds
Found 5 mxds for PDF exporting... Directory: C:\Users\is0009\Desktop\temp r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.mxd" r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_2_17x11.mxd" r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_3_17x11.mxd" r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_4_17x11.mxd" r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_5_17x11.mxd"
#Import python modules import os, sys, string, glob, arcpy.mapping #Set local variables mxdLst = glob.glob('*.mxd') mxdCnt = len(mxdLst) #### #Place script in same folder as MXDs to get 'current working directory' #### baseF = os.getcwd() #Print how many mxd's found print '\n' + 'Found ' + str(mxdCnt) + ' MXDs for exporting to PDF...' print 'Directory: ' + baseF + '\n' #For loop to process each mxd into a PDF for mxds in mxdLst: outPDF = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf' print 'Exporting ' + mxds + ' -> ' + outPDF mxd = 'r' + '\"' + baseF + '\\' + mxds + '\"' #mxd with fullpathname inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument arcpy.mapping.ExportToPDF(inMxd, outPDF) #Export mapdocument to pdf print 'Done exporting: ' + outPDF #print mxd del mxds
Found 5 MXDs for exporting to PDF... Directory: C:\Users\is0009\Desktop\temp Exporting Rural_OCP_map_1_17x11.mxd -> Rural_OCP_map_1_17x11.pdf Traceback (most recent call last): File "C:\Users\is0009\Desktop\temp\mxdloop.py", line 23, in <module> inMxd = arcpy.mapping.MapDocument(mxd) #Make current mxd in loop the mapdocument File "C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\arcobjects\mixins.py", line 443, in __init__ assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename") AssertionError: Invalid MXD filename.
import arcpy, glob, os #Place script in same folder as MXDs to get 'current working directory' baseF = os.getcwd() print baseF #Set local variables mxdLst = glob.glob(baseF + '\\' + '*.mxd') mxdCnt = len(mxdLst) #Print how many mxd's found print '\n' + 'Found ' + str(mxdCnt) + ' mxds for PDF exporting...' print 'Directory: ' + str(baseF) + '\n' #Loop to process each mxd into a PDF for mxds in mxdLst: PDFr = mxds.replace('mxd', 'pdf') #Replace 'mxd' extension with 'pdf' print 'Exporting ' + str(mxds) + ' to:' + '\n' + str(baseF) + '\\' + str(PDFr) #Print current mxd exporting and output pdf name... inMxd = arcpy.mapping.MapDocument(mxds) #Make current mxd in loop the mapdocument arcpy.mapping.ExportToPDF(inMxd, PDFr) #Export mapdocument to pdf print 'Done exporting: ' + str(PDFr) del mxds
I specified 'baseF = os.getcwd()' first and then added the baseF variable to the glob module, 'mxdLst = glob.glob(baseF + '\\' + '*.mxd')'.
inMxd = arcpy.mapping.MapDocument('\"' + mxds + '\"') #Make current mxd in loop the mapdocument
inMxd = arcpy.mapping.MapDocument('r\"' + mxds + '\"') #Make current mxd in loop the mapdocument
for mxds in mxdLst: print mxds + " is a map document"
for mxds in mxdLst: print str(mxds) + " is a map document"
inMxd = arcpy.mapping.MapDocument(mxds) #Make current mxd in loop the mapdocument
import arcpy mxd = arcpy.mapping.MapDocument(r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.mxd") print 'Exporting PDF...' arcpy.mapping.ExportToPDF(mxd, r"C:\Users\is0009\Desktop\temp\Rural_OCP_map_1_17x11.pdf") print 'Done exporting!' del mxd
Does your data within your MXDs resides within an SDE geodatabase? If so, can you try this script on an MXD that contains data from a File or Personal geodatabase?
Let's try recreating the MXD.