<?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 Re: Adding a scale and changing its position in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129737#M10089</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you loop through your ListLayoutElements variable, I bet you don't have anything in that list. This is why grabbing an index doesn't work and why grabbing a property of the MapsurroundElement object doesn't work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My guess is that your issue is with the text "ScaleBar" wildcard. Do you have anything in your layout with the name ScaleBar? Not all scale bars are named "ScaleBar", but rather, are named closer to what the text says when you click Insert &amp;gt; Scale Bar, and select a scale bar here (i.e. "Scale Line", "Stepped Scale Line", "Alternating Scale Bar", etc.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As a test, try the following to figure out what the name of your scale bar element is, and then you can use that as a wildcard in your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;scaleBar = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT")
for item in scaleBar:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print item.name&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:18:57 GMT</pubDate>
    <dc:creator>LucasDanzinger</dc:creator>
    <dc:date>2021-12-11T07:18:57Z</dc:date>
    <item>
      <title>Adding a scale and changing its position</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129736#M10088</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having trouble getting this script to run. I get errors saying line 4-list index out of range, and when I comment out the [0] I get an error saying 'list' object has no attribute 'parentDataFrameName'&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to actually add the scale bar and add in titles, author etc... with python but I was first trying to get an already inserted scale bar to change its position.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Please help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;#The following script will find the mapsurround element named ScaleBar and change it's position.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\Courtney\TEST.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;scaleBar = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT", "ScaleBar") [0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, scaleBar.parentDataFrameName)[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;scaleBar.elementPositionX = df.elementPositionX + (df.elementWidth / 2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd.save()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 15:05:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129736#M10088</guid>
      <dc:creator>courtneygarlock</dc:creator>
      <dc:date>2013-03-25T15:05:00Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a scale and changing its position</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129737#M10089</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you loop through your ListLayoutElements variable, I bet you don't have anything in that list. This is why grabbing an index doesn't work and why grabbing a property of the MapsurroundElement object doesn't work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My guess is that your issue is with the text "ScaleBar" wildcard. Do you have anything in your layout with the name ScaleBar? Not all scale bars are named "ScaleBar", but rather, are named closer to what the text says when you click Insert &amp;gt; Scale Bar, and select a scale bar here (i.e. "Scale Line", "Stepped Scale Line", "Alternating Scale Bar", etc.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As a test, try the following to figure out what the name of your scale bar element is, and then you can use that as a wildcard in your code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;scaleBar = arcpy.mapping.ListLayoutElements(mxd, "MAPSURROUND_ELEMENT")
for item in scaleBar:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print item.name&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:18:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129737#M10089</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2021-12-11T07:18:57Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a scale and changing its position</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129738#M10090</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The scale bar was "Alternating scale bar" I changed the element name to scale bar.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can change the position but is it possible to use python code to add the scale bar to the layout. I haven't found this to be possible. I can only change its properties once it is added thru arcmap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a simple script that can add and modify&amp;nbsp; title, author, dataframetime etc...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using this code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument(r"C:\Courtney\TEST1.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if elm.name == "TitleBlock":&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.text = '&amp;lt;dyn type="document" property="title"/&amp;gt;'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.elementPositionX = 3.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elm.elementPositionY = 9.0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elmfontSize = 28&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;and changing the elm.text to = author, title, dataframtime etc....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I'm looking for a script that can add these elements in regards to eachothers position so I don't have to manually set the xy &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;positions&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 18:22:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129738#M10090</guid>
      <dc:creator>courtneygarlock</dc:creator>
      <dc:date>2013-03-25T18:22:50Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a scale and changing its position</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129739#M10091</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;No there won't be python syntax to add the scale bar to the map. Broadly speaking, the mapping module is for manipulating existing maps and not for building new maps, so typically you will need to build a template map (i.e. a map with all of your layers and layout elements), and you can then manipulate that to your liking and save a copy to a new MXD.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 25 Mar 2013 21:10:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129739#M10091</guid>
      <dc:creator>LucasDanzinger</dc:creator>
      <dc:date>2013-03-25T21:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a scale and changing its position</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129740#M10092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lucas,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please let me know if we can change the existing style of a scale bar or North Arrow to another style in a layout programmatically using Python. I have searched all over the internet but could not find a methodology for this. Hope you can help me out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 08 Nov 2016 20:19:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129740#M10092</guid>
      <dc:creator>Rohit_Venkat_GandhiMendadhala4</dc:creator>
      <dc:date>2016-11-08T20:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a scale and changing its position</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129741#M10093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You cant do what you asked.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can however achieve the exact same results by:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Add 10 scale bars with unique names 'Off page', in different styles and stuff, and then use python to move them onto the&lt;/P&gt;&lt;P&gt;page as needed for different maps.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create 10 "MXD" templates with different page setups, and use the code to determine which template to use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Think of something else ..be creative!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2016 10:03:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-scale-and-changing-its-position/m-p/129741#M10093</guid>
      <dc:creator>LukeWebb</dc:creator>
      <dc:date>2016-11-10T10:03:59Z</dc:date>
    </item>
  </channel>
</rss>

