Tell me more ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
share|improve this question
1  
The first appearance of path on line 7 precedes any definition of it: that's what this error message is telling you. – whuber Mar 4 at 19:16

closed as too localized by whuber Mar 4 at 19:16

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.

If this question can be reworded to fit the rules in the help center, please edit the question.

Browse other questions tagged or ask your own question.