3

I have a feature class of points that represent storm water inlets. I am trying to automate a process that does the following.

  1. finds all of the inlets that have a field called "Marker" populated with the string "No"
  2. generate a PDF for each of these features that is a centered view at 1:50 scale.

I'm pretty new to Python. I've been working on this for awhile and keep getting an output of a single PDF (not 800, which is the aprox. # of inlets with "No") and the ArcMap crashes as the script is finishing. I'm sure my code is pretty whack!

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Oct 2, 2014 at 21:28
1
  • This is an old question but, as I am confident you now know, questions about code should always have that presented as text rather than a picture. Commented Dec 21, 2017 at 23:03

1 Answer 1

4

I would use the "SHAPE@" token with the search cursor, then do something like this:

with arcpy.da.SearchCursor(fc, ("SHAPE@", "UNIQUE_ID")) as searchCur:
 for row in searchCur:
 myDF.extent = row[0].extent
 myDF.scale = 50
 arcpy.RefreshActiveView()
 arcpy.mapping.ExportToPDF(thisMap, 
 r"N:27000円s27800円\GIS\John_Working\PDF\Map_" + str(row[1]) + ".pdf", 
 resolution=100, image_quality="Normal")
answered Oct 3, 2014 at 12:31
3
  • Thanks! this works perfectly! If you don't mind... Could you elaborate on what I was doing wrong, why is the SHAPE@ token necessary? Commented Oct 3, 2014 at 15:08
  • 1
    If you are using Search Cursor DA, you do not need to also Select the features. The cursor will go to every row in the "for row in searchCur" loop. The SHAPE@ token returns the geometry of the object, so you can grab that extent and set it as the data frame extent (myDF.extent = row[0].extent), then set the scale, refresh and export the pdf. Commented Oct 3, 2014 at 15:15
  • That makes a great deal of sense. Thank you for the explanation! Commented Oct 3, 2014 at 15:16

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.