I need someone to please check my code so I can understand how to fix it. This code is written so that a user can select an mxd, select the feature class of that mxd (to get a field that is filled with sheet numbers), and then the user picks the folder containing all the pdfs that were created from the mxd sheets. For example, Sheet 1 out of 11 is one pdf, Sheet 2 out of 11 is second pdf. I am getting the error of path is not defined. Where have I gone wrong?
import arcpy, os, string, sys
#Make parameters for people to choose mxd and folder of PDFs to compare
mxdList = string.split(arcpy.GetParameterAsText(0), ";")
dir = arcpy.GetParameterAsText(1)
fc_path = arcpy.GetParameterAsText(2)
pdfDoc = arcpy.mapping.PDFDocumentOpen(path)
#Use Search Cursor to go through Attribuite Table to get Sheet number info
for mapDoc in mxdList:
arcpy.mapping.MapDocument(mapDoc)
for lyr in m.ListLayers(mxd):
if lyr.supports('DATASOURCE'):
if lyr.dataSource == fc_path:
max_list = []
rows = arcpy.SearchCursor (mxdList, "Sheet_ID")
for row in rows:
max_list.append(row.Sheet_ID)
pdf_count = max(max_list)
arcpy.AddMessage('Sheet count: %s'%pdf_count)
else:
arcpy.AddError('No Layers in %s match data source'%mapDoc)
print pdfDoc.pageCount
path
on line 7 precedes any definition of it: that's what this error message is telling you. – whuber♦ Mar 4 at 19:16