<?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: ArcPy Scalebar Implementation Issue in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583208#M73715</link>
    <description>&lt;P&gt;you script wasn't posted&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2025 17:39:02 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2025-02-07T17:39:02Z</dc:date>
    <item>
      <title>ArcPy Scalebar Implementation Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583203#M73714</link>
      <description>&lt;P&gt;I am working on a standalone ArcPy script running FULLY out of the ArcGIS Pro application and I am running into an issue regarding the implementation of a scalebar. Currently, my script can add a scalebar however the scalebar says 0 KM and is a very small sliver shown below. I think the issue lies in the scalebar element not recognizing the map it's supposed to access. Previously this was not an issue when running the arcpy script in the ArcGIS Pro application since I used a line which include ("CURRENT") which helped the tools identify the map. If someone could help that would be great!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YahyaMasri_0-1738949041742.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124907iF44899E6CB03A995/image-size/medium?v=v2&amp;amp;px=400" role="button" title="YahyaMasri_0-1738949041742.png" alt="YahyaMasri_0-1738949041742.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:24:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583203#M73714</guid>
      <dc:creator>YahyaMasri</dc:creator>
      <dc:date>2025-02-07T17:24:23Z</dc:date>
    </item>
    <item>
      <title>ArcPy Scalebar Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583200#M73716</link>
      <description>&lt;P&gt;I am working on a standalone ArcPy script running FULLY out of the ArcGIS Pro application and I am running into an issue regarding the implementation of a scalebar. Currently, my script can add a scalebar however the scalebar says 0 KM and is a very small sliver shown below. I think the issue lies in the scalebar element not recognizing the map it's supposed to access. Previously this was not an issue when running the arcpy script in the ArcGIS Pro application since I used a line which include ("CURRENT") which helped the tools identify the map. If someone could help that would be great!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-02-07 at 12.19.28 PM.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124906i61875DED5E3EA90F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2025-02-07 at 12.19.28 PM.png" alt="Screenshot 2025-02-07 at 12.19.28 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:20:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583200#M73716</guid>
      <dc:creator>YahyaMasri</dc:creator>
      <dc:date>2025-02-07T17:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Scalebar Implementation Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583208#M73715</link>
      <description>&lt;P&gt;you script wasn't posted&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 17:39:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583208#M73715</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-02-07T17:39:02Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Scalebar Implementation Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583246#M73717</link>
      <description>&lt;LI-CODE lang="python"&gt;def mapLayout(map_title):
                            def MakeRec_LL(llx, lly, w, h):
                                xyRecList = [
                                    [llx, lly],
                                    [llx, lly + h],
                                    [llx + w, lly + h],
                                    [llx + w, lly],
                                    [llx, lly]
                                ]
                                array = arcpy.Array([arcpy.Point(*coords) for coords in xyRecList])
                                rec = arcpy.Polygon(array)
                                return rec

                            p = arcpy.mp.ArcGISProject(new_aprx_path)
                            lyt = p.createLayout(17, 11, 'INCH')
                            m = p.listMaps("Map")[0]

                            # Adjust the map frame to be larger
                            map_frame_width, map_frame_height = 14, 8  # Adjusted to make the map larger
                            map_frame_x = (17 - map_frame_width) / 2
                            map_frame_y = (11 - map_frame_height) / 2   # Adjusted for the larger map size

                            mf = lyt.createMapFrame(
                                MakeRec_LL(map_frame_x, map_frame_y, map_frame_width, map_frame_height),
                                m,
                                "New Map Frame"
                            )

                            #SCALEBAR
                            scale_bar_width = 2.5
                            scale_bar_height = 0.3
                            scale_bar_x = map_frame_x + 0.2
                            scale_bar_y = map_frame_y - 0.6
                            sbEnv = MakeRec_LL(scale_bar_x, scale_bar_y, scale_bar_width, scale_bar_height)

                            sbName = 'Scale Line 1 Metric'
                            sbStyle = p.listStyleItems('ArcGIS 2D', 'Scale_bar', sbName)[0]
                            sb = lyt.createMapSurroundElement(sbEnv, 'Scale_bar', mf, sbStyle, 'My Scale Bar')
                            sb.elementWidth = 3.5&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 07 Feb 2025 18:52:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583246#M73717</guid>
      <dc:creator>YahyaMasri</dc:creator>
      <dc:date>2025-02-07T18:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Scalebar Implementation Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583349#M73718</link>
      <description>&lt;P&gt;Try this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;scalebars = layout.listElements("MAPSURROUND_ELEMENT")
    sb = None
    for s in scalebars:
        if s.name == "Scale Bar":
            sb = s
            break

    if sb:
        print(f"Scalebar Found: {sb.name}")

        # Scalebar linked to the map frame
        if sb.mapFrame.name != mf.name:
            sb.mapFrame = mf  # map frame
            print(f"Scalebar linked to map frame: {mf.name}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 22:05:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583349#M73718</guid>
      <dc:creator>TonyAlmeida</dc:creator>
      <dc:date>2025-02-07T22:05:31Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPy Scalebar Implementation Issue</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583431#M73719</link>
      <description>&lt;P&gt;Awesome, worked great! Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Feb 2025 23:28:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-scalebar-implementation-issue/m-p/1583431#M73719</guid>
      <dc:creator>YahyaMasri</dc:creator>
      <dc:date>2025-02-08T23:28:44Z</dc:date>
    </item>
  </channel>
</rss>

