I'm trying to create three map layouts and export them into PDFs using ModelBuilder in ArcGIS Pro. However, when I try to reference the three bookmarks (AAA, Amityville, and Astoria) to be used for the layouts, I get an error.
Here is a section of my code from a custom script tool that I am having trouble with:
# setting layout to bookmark aprx = arcpy.mp.ArcGISProject("Current") # add name of layout lyt = aprx.listLayouts("Layout_King") mf = lyt.listElements("MAPFRAME_ELEMENT") # add name of bookmark bkmks = mf.map.listBookmarks('AAA','Amityville','Astoria') bkmks.sort(key=lambda x: x.name, reverse=True) for bkmk in bkmks: mf.zoomToBookmark(bkmk) legend.autoAdd = True time.sleep(5) lyt.exportToPDF(r"C:\arcGIS_Shared\Exports" + "\\" + bkmk.name + ".pdf")
The error I'm getting is:
Traceback (most recent call last): File "C:\arcGIS_Shared\PythonTest_2\Layout_Bookmark_Export_Script.py", line 42, in <module> bkmks = mf.map.listBookmarks('AAA','Amityville','Astoria') TypeError: listBookmarks() takes from 1 to 2 positional arguments but 4 were given Failed to execute (Layout Bookmark Export)