<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Script Tool - Reference Bookmarks in Alphabetical Order in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339314#M26587</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;I have a custom script tool that is supposed to set up a map layout, by adjusting the scale bar, north arrow, title, and legend. It is then supposed to reference a bookmark and export the layout as a PDF.&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;The problem is that when I use this tool in ModelBuilder it references the wrong bookmarks.&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;I'm using this script tool in ModelBuilder for ArcGIS Pro. This model iterates through Urgent Care centers and its corresponding data one at a time (in alphabetical order by center name). I have bookmarks for every Urgent Care center, so my thought is that, if I can find a way for the model to reference the bookmarks in alphabetical order, then they will correspond with the correct Urgent Care center.&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Could this be achieved via a table or list Index, or some kind of loop? Or is there a better way to go about this whole process?&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Here is the code from the script tool I am using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1872765406"&gt;input layer&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyr = arcpy.GetParameterAsText(0)&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--679391555"&gt;input name of layout&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;p = arcpy.mp.ArcGISProject("CURRENT") 
lyt = p.listLayouts("Layout_King")[0]&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1063418780"&gt;Reposition the scale bar&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;scaleBar = lyt.listElements("MAPSURROUND_ELEMENT", "Scale Bar")[0] 
mf = scaleBar.mapFrame 
scaleBar.elementPositionX = mf.elementPositionX + 0.0 
scaleBar.elementPositionY = mf.elementPositionY - 0.5&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--1488738181"&gt;Reposition the north arrow&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;northArrow = lyt.listElements("MAPSURROUND_ELEMENT", "North Arrow")[0] 
mf = northArrow.mapFrame 
northArrow.elementPositionX = mf.elementPositionX + 8.8 
northArrow.elementPositionY = mf.elementPositionY + 0.7&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-254072154"&gt;Align the title with the center of the map frame&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;title = lyt.listElements("TEXT_ELEMENT","Name of Map Text")[0] 
mf = lyt.listElements('MAPFRAME_ELEMENT',"Map Frame")[0] 
title.elementPositionX = mf.elementPositionX + (mf.elementWidth / 3.7) 
title.elementPositionY = mf.elementPositionY + (mf.elementHeight / 0.98)&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1996882489"&gt;Reposition the Legend and fix legend title&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;legend = lyt.listElements("LEGEND_ELEMENT", "Legend")[0] 
legend.title = "Legend" 
legend.elementPositionX = mf.elementPositionX + 7.7 
legend.elementPositionY = mf.elementPositionY + 7.15&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--555274472"&gt;setting layout to bookmark&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;aprx = arcpy.mp.ArcGISProject("Current")&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1187535863"&gt;add name of layout&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyt = aprx.listLayouts("Layout_King")[0] mf = lyt.listElements("MAPFRAME_ELEMENT")[0]&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--1364621098"&gt;add name of bookmark&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;bkmks = mf.map.listBookmarks("*") 
for bkmk in bkmks:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;mf.zoomToBookmark(bkmk) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;lyt.exportToPDF(r"C:\arcGIS_Shared\Exports" + "\\" + bkmk.name + ".pdf")&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 16:03:01 GMT</pubDate>
    <dc:creator>Business_IntelligenceSoftware</dc:creator>
    <dc:date>2021-12-11T16:03:01Z</dc:date>
    <item>
      <title>Script Tool - Reference Bookmarks in Alphabetical Order</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339314#M26587</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;I have a custom script tool that is supposed to set up a map layout, by adjusting the scale bar, north arrow, title, and legend. It is then supposed to reference a bookmark and export the layout as a PDF.&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;The problem is that when I use this tool in ModelBuilder it references the wrong bookmarks.&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;I'm using this script tool in ModelBuilder for ArcGIS Pro. This model iterates through Urgent Care centers and its corresponding data one at a time (in alphabetical order by center name). I have bookmarks for every Urgent Care center, so my thought is that, if I can find a way for the model to reference the bookmarks in alphabetical order, then they will correspond with the correct Urgent Care center.&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Could this be achieved via a table or list Index, or some kind of loop? Or is there a better way to go about this whole process?&lt;/P&gt;&lt;P style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; margin: 0px 0px 1em; padding: 0px;"&gt;Here is the code from the script tool I am using.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;import arcpy&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1872765406"&gt;input layer&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyr = arcpy.GetParameterAsText(0)&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--679391555"&gt;input name of layout&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;p = arcpy.mp.ArcGISProject("CURRENT") 
lyt = p.listLayouts("Layout_King")[0]&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1063418780"&gt;Reposition the scale bar&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;scaleBar = lyt.listElements("MAPSURROUND_ELEMENT", "Scale Bar")[0] 
mf = scaleBar.mapFrame 
scaleBar.elementPositionX = mf.elementPositionX + 0.0 
scaleBar.elementPositionY = mf.elementPositionY - 0.5&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--1488738181"&gt;Reposition the north arrow&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;northArrow = lyt.listElements("MAPSURROUND_ELEMENT", "North Arrow")[0] 
mf = northArrow.mapFrame 
northArrow.elementPositionX = mf.elementPositionX + 8.8 
northArrow.elementPositionY = mf.elementPositionY + 0.7&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-254072154"&gt;Align the title with the center of the map frame&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;title = lyt.listElements("TEXT_ELEMENT","Name of Map Text")[0] 
mf = lyt.listElements('MAPFRAME_ELEMENT',"Map Frame")[0] 
title.elementPositionX = mf.elementPositionX + (mf.elementWidth / 3.7) 
title.elementPositionY = mf.elementPositionY + (mf.elementHeight / 0.98)&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1996882489"&gt;Reposition the Legend and fix legend title&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;legend = lyt.listElements("LEGEND_ELEMENT", "Legend")[0] 
legend.title = "Legend" 
legend.elementPositionX = mf.elementPositionX + 7.7 
legend.elementPositionY = mf.elementPositionY + 7.15&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--555274472"&gt;setting layout to bookmark&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;aprx = arcpy.mp.ArcGISProject("Current")&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId-1187535863"&gt;add name of layout&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;lyt = aprx.listLayouts("Layout_King")[0] mf = lyt.listElements("MAPFRAME_ELEMENT")[0]&lt;/CODE&gt;&lt;/PRE&gt;&lt;H1 style="color: #242729; background-color: rgba(248, 248, 248, 0.6); border: 0px; font-weight: bold !important; font-size: 21px; margin: 0px 0px 1em; padding: 0px;" id="toc-hId--1364621098"&gt;add name of bookmark&lt;/H1&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;bkmks = mf.map.listBookmarks("*") 
for bkmk in bkmks:&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;mf.zoomToBookmark(bkmk) 
&amp;nbsp;&amp;nbsp;&amp;nbsp;lyt.exportToPDF(r"C:\arcGIS_Shared\Exports" + "\\" + bkmk.name + ".pdf")&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339314#M26587</guid>
      <dc:creator>Business_IntelligenceSoftware</dc:creator>
      <dc:date>2021-12-11T16:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do you convert this python code to a script tool?</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339315#M26588</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting"&gt;&lt;STRONG&gt;Code Formatting the Basics++&lt;/STRONG&gt;&lt;/A&gt; would be useful to get the code into shape. &amp;nbsp;&lt;/P&gt;&lt;P&gt;And what does your modelbuilder model do? perhaps it would be way easier to go whole code rather than a combo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 18:44:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339315#M26588</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2017-11-20T18:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you convert this python code to a script tool?</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339316#M26589</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I work for an urgent care company and this model creates a table for&amp;nbsp;an urgent care center we have, along with the patient data for that center. The model then geocodes the addresses for the patients and then performs a summarize within using census blocks and the patient geocoded locations. The next step in the model (which I need help with) is a script tool that will create a layout for&amp;nbsp;the center by referencing a bookmark and export it as a PDF.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully that clarifies what I'm trying to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've read all the web pages on creating script tools, but it is still confusing to know when to&amp;nbsp;use the GetParameterAsText and to know what data type to use when setting the tool parameters&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Nov 2017 19:59:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-reference-bookmarks-in-alphabetical/m-p/339316#M26589</guid>
      <dc:creator>Business_IntelligenceSoftware</dc:creator>
      <dc:date>2017-11-20T19:59:11Z</dc:date>
    </item>
  </channel>
</rss>

