I am running a script to export a series of mxds to pdf via ArcPy in an ArcToolbox tool (code below). I already reduced it to the minimum of code necessary but still, NON REPRODUCIBLE, I get a Microsft Visual C++ Runtime Error r6205 "pure virtual function called". This happens with different mxd on all kinds of different Win7 machines. ArcGIS version is 10.1.

Here is the code:

#Load necessary modules
import arcpy, os, string

#Read input parameters from script tool
mxdList = string.split(arcpy.GetParameterAsText(0), ";")
outPDFpath = arcpy.GetParameterAsText(1)
resol = arcpy.GetParameter(2)
imQal = arcpy.GetParameterAsText(3)
comVec = arcpy.GetParameterAsText(4)
comImg = arcpy.GetParameterAsText(5)
picSym = arcpy.GetParameterAsText(6)
conMark = arcpy.GetParameterAsText(7)
embFo = arcpy.GetParameterAsText(8)
comJPG = arcpy.GetParameterAsText(9)

mxdList = [mxdPath[1:-1] for mxdPath in mxdList]

#Statusbar for rough prediction of duration
#totLength = len(mxdList)
#arcpy.SetProgressor("step", "Exporting Maps to PDF...",
#                    0, totLength, 1)

#If folder not existing -> create
if not os.path.exists(outPDFpath):

# Send Message to Operator
#if totLength <= 10:
#    arcpy.AddWarning("\n Dear Operator, this might take a while. Get an icecram or a quick coffee. \n")
#if totLength > 10:
#    arcpy.AddWarning("\n Dear Operator, this might take a damn good while. Get a beer or two. \n")

#Loop through each MXD in the list, export, output PDF
for mxdPath in mxdList:
    mxd = arcpy.mapping.MapDocument(mxdPath)
    mxdName = os.path.splitext(os.path.basename(mxdPath))[0]
    PDFPath = outPDFpath + "\\" + mxdName + ".pdf"
    #Short message to the operator which Map is being processed now
    #arcpy.SetProgressorLabel("Exporting Map to PDF:\n" + mxdPath)
    arcpy.mapping.ExportToPDF(mxd, PDFPath,
                              resolution = resol,
                              image_quality = imQal,
                              compress_vectors = comVec,
                              image_compression = comImg,
                              picture_symbol = picSym,
                              convert_markers = conMark,
                              embed_fonts = embFo,
                              jpeg_compression_quality = comJPG)

    # Update the progressor position
    # Send Message to Statuswindow
    #arcpy.AddMessage("\n Supersuccess: " + PDFPath + " created! Processing next file. \n")

#Remove variable reference to file
del mxd, mxdList, outPDFpath, mxdName, PDFPath

Previous research indicated that all status message related functions might be likely to cause such a crash, so they are commented out.

Does anyone see an error in my code? I am just stuck with finding a solution.

  • There's two issues here: 1) Are you using the terminal build of 10.1 (SP1 + two score of patches)? 2) Have you tried using a recent build of ArcGIS (10.3.1 or 10.4.1)? 10.1 is in Mature support status, so even if this was a new software issue, there isn't going to be a patch. That said, crash issues are the proper domain of Esri Tech Support; there isn't really anything anyone here can do. – Vince Jun 14 '16 at 15:19
  • Can you run just the arcpy.mapping.ExportToPDF() command using the exact same inputs (1 MXD) from the Python command line inside ArcCatalog? If the answer is "Yes" then we know it should work. That would lead us to the conclusion that something is wrong with either your inputs or how your script is processing the inputs. For example, are you passing a string instead of an integer into the jpeg compression variable, or are your paths being processed correctly? – alexGIS Jun 14 '16 at 18:32

Late reply but still: I tried and checked your suggestions @Vince and @alexGIS.

Final solution now was that my company upgraded to Version 10.4.1 and it works just fine now. So it seems like it really was a bug of some sort with 10.1.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.