Solved! Go to Solution.
import arcpy import pythonaddins class testExtension(object): """Implementation for arcAddin_addin.testExtension (Extension)""" def __init__(self): # For performance considerations, please remove all unused methods in this class. self.enabled = True self.testTxt = open('D:\\_TEMP\\testOutput.txt', 'w') self.testTxt.write('File created') self.testTxt.flush() def openDocument(self): self.testTxt.write('!! openDocument method...') self.testTxt.flush() mxd = arcpy.mapping.MapDocument("CURRENT") if mxd.description == 'Print to PDF': self.testTxt.write('\t\tDocument contains "Print to PDF" description') self.testTxt.flush() arcpy.mapping.PrintMap(mxd, r"Adobe PDF", "PAGE_LAYOUT") layers = arcpy.mapping.ListLayers(mxd, "", "Layers"): self.testTxt.write('\t\t%s' % str(layers)) self.testTxt.flush() self.testTxt.write('\t\tAbout to kill ArcMap') self.testTxt.flush() os.system('taskkill /IM Arcmap*') self.testTxt.write('\t\tThis probably will not appear in the file...') self.testTxt.flush() else: self.testTxt.write('\t\tDocument DOES NOT contain "Print to PDF" description') self.testTxt.flush() def beforeCloseDocument(self): self.testTxt.write('!! beforeCloseDocument method') self.testTxt.flush() def closeDocument(self): self.testTxt.write('!! closeDocument method') self.testTxt.flush()
Stacy,
I've had some success. I'm running late getting out of the office today, but I plan to write it all up on Monday. Your never going to believe how I got it to work. Sorry to leave you hanging in suspense over the weekend.
Eric
import arcpy import subprocess strArcMapPath = r"C:\Program Files (x86)\ArcGIS\Desktop10.1\bin\ArcMap.exe" strMxd = r"D:\Users\Products\PSA Map Updates\Automation\PSA Location Map - Final.mxd" objNewProcess = subprocess.Popen([strArcMapPath, strMxd]) objNewProcess.wait() # this line will wait for the new process to end print "Script completed successfully."
import arcpy import pythonaddins class ExtensionClass1(object): """Implementation for PrintToPDF_AddIn_addin.extension2 (Extension)""" def __init__(self): # For performance considerations, please remove all unused methods in this class. self.enabled = True def openDocument(self): mxd = arcpy.mapping.MapDocument("CURRENT") if mxd.description == 'Print to PDF': arcpy.mapping.PrintMap(mxd, r"Adobe PDF", "PAGE_LAYOUT")