<?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: How do I change the Scalebar Units between feet and miles depending on the Map scale in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1328432#M10385</link>
    <description>&lt;P&gt;I have found this documentation -&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/pdf/projected_coordinate_systems.pdf" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/pdf/projected_coordinate_systems.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For foot use WKID 9002. For&amp;nbsp;Statute_Mile, use wkid 9093&lt;/P&gt;</description>
    <pubDate>Wed, 13 Sep 2023 18:25:05 GMT</pubDate>
    <dc:creator>HelenZhou</dc:creator>
    <dc:date>2023-09-13T18:25:05Z</dc:date>
    <item>
      <title>How do I change the Scalebar Units between feet and miles depending on the Map scale</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1211005#M8728</link>
      <description>&lt;P&gt;I have an alternating scalebar in my layout.&amp;nbsp; In my Addin the user selects features they want to locate on the map and zooms to their selection.&amp;nbsp; As long as the map scale required to display all of the features is not zoomed out beyond 1:4000 feet I want the scalebar units to be displayed in Feet and adjust the map scale to make sense for feet.&amp;nbsp; If the map has to zoom out beyond 1:4000 feet to display all of the features I adjust the scale to the nearest 1/2 mile interval that contains all of the features and want the scalebar units to be displayed in Miles.&amp;nbsp; I want to programmatically change the UnitLabel and Units of the scalebar to either feet or miles depending on the scale of the map.&amp;nbsp; I have figured out hoe to access Scalebar's UnitLabel and Units properties.&amp;nbsp; The UnitLabel is set as a string, but the Units needs to be set as an ArcGIS.Core.Geometry.Unit.&amp;nbsp; When I get the Units from the Scalebar as a ArcGIS.Core.Geometry.Unit variable all of its properties that I want to change are read only.&amp;nbsp; How do I set up an instance of an ArcGIS.Core.Geometry.Unit for feet and for Miles so I can set the Scalebar Units property to match the unit rules I am applying to the map scale my Addin is setting?&lt;/P&gt;&lt;P&gt;Here is code I have so far:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ScaleBar alternatingScaleBar = lyt.FindElement("Alternating Scale Bar") as ScaleBar;
                            if (alternatingScaleBar != null)
                            {
                                CIMDoubleFillScaleBar dfScaleBar = alternatingScaleBar.GetDefinition() as CIMDoubleFillScaleBar;
                                dfScaleBar.UnitLabel = "Feet";
                                // I can get the current unit setting of
                                // the scalebar with this code, but I can't
                                // change the unit setting of this variable
                                // and I don't know how to set up my own
                                // ArcGIS.Core.Geometry.Unit variable that
                                // I can use to change the Units property.
                                var sbUnits = dfScaleBar.Units;
                            }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 09 Sep 2022 01:44:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1211005#M8728</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2022-09-09T01:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the Scalebar Units between feet and miles depending on the Map scale</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1211167#M8735</link>
      <description>&lt;P&gt;I figured out the answer.&amp;nbsp; Here is the code I came up with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var ActMap = MapView.Active;
MapView mapView = ActMap;
Camera camera = mapView.Camera;
double scaleFt = camera.Scale/12; // Convert inches to feet
ScaleBar alternatingScaleBar = lyt.FindElement("Alternating Scale Bar") as ScaleBar;
if (alternatingScaleBar != null)
{
    CIMDoubleFillScaleBar scaleBarDef = alternatingScaleBar.GetDefinition() as CIMDoubleFillScaleBar;
    if (scaleFt &amp;lt;= 4000)
    {
        scaleBarDef.UnitLabel = "Ft";
        string unitJsonFt = "{\"uwkid\":9002}";
        var unitFt = ArcGIS.Core.Geometry.Unit.CreateFromJson(unitJsonFt);
        scaleBarDef.Units = unitFt;
    }
    else
    {
        scaleBarDef.UnitLabel = "Mi";
        string unitJsonMi = "{\"uwkid\":9093}";
        var unitMi = ArcGIS.Core.Geometry.Unit.CreateFromJson(unitJsonMi);
        scaleBarDef.Units = unitMi;
    }
    alternatingScaleBar.SetDefinition(scaleBarDef);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2022 17:07:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1211167#M8735</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2022-09-09T17:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the Scalebar Units between feet and miles depending on the Map scale</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1328011#M10380</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3788"&gt;@RichardFairhurst&lt;/a&gt;&amp;nbsp;, how is the json constructed?&amp;nbsp;"{\"uwkid\":9002}"&amp;nbsp; ?&lt;/P&gt;&lt;P&gt;It is related with spatial reference wkid or is&amp;nbsp; this just for generic feet? where do I find the reference to construct the json for feet unit in spatial reference like 2276? Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2023 21:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1328011#M10380</guid>
      <dc:creator>HelenZhou</dc:creator>
      <dc:date>2023-09-12T21:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do I change the Scalebar Units between feet and miles depending on the Map scale</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1328432#M10385</link>
      <description>&lt;P&gt;I have found this documentation -&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/pdf/projected_coordinate_systems.pdf" target="_blank"&gt;https://pro.arcgis.com/en/pro-app/latest/help/mapping/properties/pdf/projected_coordinate_systems.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For foot use WKID 9002. For&amp;nbsp;Statute_Mile, use wkid 9093&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 18:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-do-i-change-the-scalebar-units-between-feet/m-p/1328432#M10385</guid>
      <dc:creator>HelenZhou</dc:creator>
      <dc:date>2023-09-13T18:25:05Z</dc:date>
    </item>
  </channel>
</rss>

