Works in ArcGIS Pro Python Console but FUBAR with script tool

Discussion created by BradleyJones on Sep 23, 2019
Latest reply on Sep 25, 2019 by curtvprice

I have an old script tool that I'm migrating to ArcGIS Pro.  The tool only has two parameters (Subbasin: string, Directory: folder)  and it is supposed export a PDF mapbook of the features for the subbasin number entered.


I wrote the code and tested it in the Python console window in Pro. It works fine. I have exported >20 mapbooks.


I configured it as a script tool and two things happen:

  1. Whatever subbasin is entered, the resulting section set for mapsheets is always the selection set that was desired on the previous run of the tool—seriously weird!
  2. The PDF export file is never created. The exportToPDF function seems to run, but no file is generated and no exception is thrown.





The logic is as follows:

  1. Check the map for the required layers
  2. Apply the definition query for the desired subbasin
  3. Perform selections to get the desired mapsheet grid
    1. Select inspection results for the desired subbasin
    2. Select mapsheets for previously selected inspection results
  4. Apply definition query to based on mapsheet selection
    1. Get selection set for mapsheet
    2. Use selection set to make query string for definition query.
    3. Apply definition query to Inspection Mapsheets layer
  5. Change Layout text elements
  6. Refresh map series
  7. Export map series as PDF 


I added the mapbook derived output the last time i tried to get it to work.