ArcGIS Pro 2.9 API Reference Guide
ScaleBar Class
Members  Example 

ArcGIS.Desktop.Layouts Namespace : ScaleBar Class
Represents a scale bar on a page layout.
Object Model
ScaleBar ClassCoordinate2D StructureEnvelope ClassCIMElement ClassIElementParent InterfaceMapFrame Class
Syntax
Remarks
There are currently no additional members but this class can be used to determine the type of MapSurround..
Example
//Create a scale bar for a specific map frame and assign a scale bar style item.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Reference a North Arrow in a style
  StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>().FirstOrDefault(item => item.Name == "ArcGIS 2D");
  ScaleBarStyleItem sbStyleItm = stylePrjItm.SearchScaleBars("Double Alternating Scale Bar 1")[0];

  //Build geometry
  Coordinate2D center = new Coordinate2D(7, 8);

  //Reference MF, create north arrow and add to layout 
  MapFrame mf = layout.FindElement("New Map Frame") as MapFrame;
  if (mf == null)
  {
    ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Map frame not found", "WARNING");
    return;
  }
  ScaleBar sbElm = LayoutElementFactory.Instance.CreateScaleBar(layout, center, mf, sbStyleItm);
  sbElm.SetName("New Scale Bar");
  sbElm.SetWidth(2);
  sbElm.SetX(6);
  sbElm.SetY(7.5);
});
Inheritance Hierarchy

System.Object
   ArcGIS.Desktop.Framework.Contracts.PropertyChangedBase
      ArcGIS.Desktop.Layouts.Element
         ArcGIS.Desktop.Layouts.MapSurround
            ArcGIS.Desktop.Layouts.ScaleBar

Requirements

Target Platforms: Windows 11, Windows 10, Windows 8.1

See Also

Reference

ScaleBar Members
ArcGIS.Desktop.Layouts Namespace