ArcGIS Pro 3.7 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / StyleHelper Class / SearchNorthArrows Method
The StyleProjectItem to search.
The search term.
Example

In This Topic
    SearchNorthArrows Method
    In This Topic
    Returns a collection of north arrow style items that satisfy the search criteria. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax

    Parameters

    styleProjectItem
    The StyleProjectItem to search.
    searchString
    The search term.

    Return Value

    A collection of NorthArrowStyleItem.
    Exceptions
    ExceptionDescription
    This method must be called within the lambda passed to QueuedTask.Run
    Example
    Create North Arrow From StyleItem 1
    {
      //Create a north arrow using a style.
    
      //Search for a style project item by name
      StyleProjectItem arcgis2dStyles = Project.Current.GetItems<StyleProjectItem>()
                        .First(si => si.Name == "ArcGIS 2D");
    
      //Construct on the worker thread
    
      NorthArrowStyleItem naStyleItem = arcgis2dStyles.SearchNorthArrows(
                    "ArcGIS North 13").FirstOrDefault();
    
      //Reference the map frame and define the location
      MapFrame newFrame = layout.FindElement("New Map Frame") as MapFrame;
      Coordinate2D nArrow = new Coordinate2D(6, 2.5);
    
      //Construct the north arrow
    
      var naInfo = new NorthArrowInfo()
      {
        MapFrameName = newFrame.Name,
        NorthArrowStyleItem = naStyleItem
      };
      var newNorthArrow = ElementFactory.Instance.CreateMapSurroundElement(
                              layout, nArrow.ToMapPoint(), naInfo);
    }
    Create North Arrow From StyleItem 2
    {
      //Note: Must be on QueuedTask.Run
    
      //Build geometry
      Coordinate2D center = new Coordinate2D(7, 5.5);
    
      //Reference a North Arrow in a style
      StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>()
                                     .FirstOrDefault(item => item.Name == "ArcGIS 2D");
      NorthArrowStyleItem naStyleItm = stylePrjItm.SearchNorthArrows(
                                             "ArcGIS North 10")[0];
    
      //Reference MF, create north arrow and add to layout 
    
      var mf = layout.FindElement("Map Frame") as MapFrame;
      var narrow_info = new NorthArrowInfo()
      {
        MapFrameName = mf.Name,
        NorthArrowStyleItem = naStyleItm
      };
      var arrowElm = (NorthArrow)ElementFactory.Instance.CreateMapSurroundElement(
        layout, center.ToMapPoint(), narrow_info) as NorthArrow;
      arrowElm.SetName("New North Arrow");
      arrowElm.SetHeight(1.75);
      arrowElm.SetX(7);
      arrowElm.SetY(6);
    }
    How to search for north arrows in a style
    {
        //Search for north arrows
        //Note: styleProjectItem was created above in the variable initialization section
        //Note: Needs QueuedTask to run
        styleProjectItem.SearchNorthArrows("searchString");
    }
    Requirements

    Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)

    ArcGIS Pro version: 3.0 or higher.
    See Also