I am currently trying to use modelbuilder to go through each row in an attribute table, select the streets that intersect the polygon (which is the row in the attribute table), zoom to the selected features, apply a definition-query to show only the currently selected polygon and the roads, then export the current layout as a pdf.

For example, say you have a 4x4 group of polygons labeled like so


What I am trying to do is:

  1. select the row that correlates to F
  2. select the streets that intersect it,
  3. zoom to the polygon with the streets selected,
  4. apply a definition query so that I can only see F and the streets that intersect it, and then
  5. export the map layout as a pdf and then
  6. go on to do the exact same thing for G, then H, and so on.

Is this feasible to do with modelbuilder/python, or would it just be easier to use other methods like data driven pages and manually apply the definition-query?

I have included the portion of the code that I have managed to get working in model builder below.

import arcpy

arcpy.ImportToolbox("Model Functions")

cotgis11_COTGIS_Block_Watch__2_ = "cotgis11.COTGIS.Block_Watch"
Streets_59_999_to_10_000 = "Streets 59,999 to 10,000"
I_cotgis11_COTGIS_Block_Watc = "I_cotgis11.COTGIS_Block_Watc"

arcpy.IterateRowSelection_mb(cotgis11_COTGIS_Block_Watch__2_, "Block_Watc #", "false")

arcpy.SelectLayerByLocation_management(Streets_59_999_to_10_000, "INTERSECT", I_cotgis11_COTGIS_Block_Watc, "50 Feet", "NEW_SELECTION")

arcpy.CalculateValue_management("zoomToSelectedFeatures()", "import arcpy\\ndef zoomToSelectedFeatures():\\n        mxd = arcpy.mapping.MapDocument('CURRENT')\\n        df = arcpy.mapping.ListDataFrames(mxd,\"Layers\")[0]\\n        df.zoomToSelectedFeatures()\\n        arcpy.RefreshActiveView() ", "Feature Layer")
  • This is relatively easy to do using arcpy.mapping so, in this instance, I would abandon ModelBuilder and the code you have exported from it. I would start by getting a SearchCursor working that reads and prints the rows from your polygon feature class. – PolyGeo Aug 15 '13 at 22:03
  • @PolyGeo Thanks for the comment with advice on what to do. Unfortunately, I am not all that good in programming and my other co-workers are at a loss as well on how to progress with the python aspect. I managed to get the SearchCursor to spit out the rows, but that was all I could manage. – Alex Gross Aug 16 '13 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.