I have an toolbox .tbx running a python / arcpy script that exports the layout to PDF and EPS . This toolbox worked in 2.7 , but now hangs in 2.8 . The lines it hangs on is:
The same issue also occurs on:
No exceptions are caught, the application just spins and does not return from the method call. Pressing cancel on the running toolbox does not stop this. Only killing the application in the task manager exits this. Oddly, the PDF file is created.
In the python window, the following code works as expected and does not hang:
aprx = arcpy.mp.ArcGISProject("current")
the_layout = aprx.listLayouts("letter_portrait")
Solved! Go to Solution.
I can NOT reproduce this issue using the code you have above. Can you reproduce with other layouts in other projects? Is there something unique about the project, the data, do you have multiple layouts with the same name, etc?
The layout creates correctly, and the code works in the python window. It is only when it is run through a toolbox (.tbx) that it hangs on exportToPDF (after the layout has already been successfully created). There are no duplicate layout names. The toolbox can be brought into any 2.8 project, and will fail/hang. The toolbox can be brought into any 2.7 project, and it will succeed.
Ian, I can NOT reproduce, even on 2.8 final. Just to be clear, I've created a script tool in a toolbox (tbx) that has no parameters and runs your 3 lines of code.
Again, can you reproduce this issue with other projects / layouts? I could be data specific. In these cases it makes the most sense to open an Esri support instance where they have the resources to help you diagnose the problem.
Jeff = Layout and arcpy.mp teams
Thank you for the note. You are correct. When I create a simple tbx with the three line script, I am unable to get the script to hang. Unfortunately, the PDF that is created shows the layout elements, but the map is blank / missing.
I will work to get a concrete example that results in the hanging I am experiencing with my existing production toolbox.
Ian, the map not displaying is an interesting clue. If your steps are clear and reproducible and you can produce a project package (ppkx), you are welcome to send it directly to me (email@example.com).
Ian, we might have found the cause. Do you have any layers with labels that use simple or advanced Python expressions? A customer just reported they are having a similar hang as you and turning off the labeled or changing the expression engine (eg., to Arcade) allows export.
Jeff - Layout and arcpy.mp teams
Thank you for the note. The labels are all Arcade expressions. I simplified the expressions and turned off the labeling:
the_layer.showLabels = False
Unfortunately, exportToPDF still hangs.
That is unfortunate. I hoped we had a solution. 2 others have confirmed my findings. The best thing to do is to somehow get a reproducible case to technical support so your situation can be evaluated.
I found a work around for now. Adding a sleep for 3 seconds prior to running the export allows the export to run correctly (sleeping for 1 second still hangs).