I have written a code to count sheets or pages in an mxd. How would I print a message before the display of the count result? For Example: the count is 11. I want it to display "Sheet Count : 11". My code is below:

import arcpy, os, sys, string
from os import path as p
from arcpy import mapping as m

Make parameters for people to choose mxd and folder of PDFs to compare

mxdList = arcpy.GetParameterAsText(0).split(";")
pdf_path = arcpy.GetParameterAsText(1)

Use Search Cursor to go through Attribuite Table to get Sheet number info

count = 0
mxd_dict = {}
for mapDoc in mxdList:
    mxd = arcpy.mapping.MapDocument(mapDoc)
    max_list = []
    for lyr in m.ListLayers(mxd):
            rows = arcpy.SearchCursor(lyr)
            for row in rows:
                count += 1
            sheet_count = max(max_list)
            mxd_name = p.basename(mapDoc).split('.')[0]
            mxd_dict[mxd_name] = sheet_count

arcpy.AddMessage (count)
 Right here is probably where I need the code. Sheet Count : 
  • Please review some of your previous questions, do not just abandon them. This does not encourage the people that have tried to help you previously.
    – blah238
    Mar 11 '13 at 17:07
  • Thanks for the advice. But this is not the same question as before. This question is asking how I can display the rows counted in the result window when the code runs. For Example: Sheet Count = 11. Mar 11 '13 at 17:32
  • It looks like exactly the same question to me, the only thing that has changed is a little bit of code which you can and should update in the original question by editing it.
    – blah238
    Mar 11 '13 at 17:35
  • Michelle, please click the checkmark next to @KHibma's answer to reflect that you have "accepted" his answer as best or what worked for you. Thanks. Mar 11 '13 at 18:37

There are are number of ways you can write out messages with AddMessage. I personally prefer this way:

arcpy.AddMessage("Sheet count: {0}".format(count))

Sheet count: 11

You can continue to add more variables in that style, for example

arcpy.AddMessage("Processing sheet {0} of {1}".format(counter, total))

Processing sheet 2 of 30

  • Thank You so much for your help. The first one worked perfectly. Have a good day! Mar 11 '13 at 17:34

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