{
var project = Project.Current;
await QueuedTask.Run(() =>
{
//Get the Style project items in the project
var styleProjectItems = project?.GetItems<StyleProjectItem>();
//Get the ArcGIS 2D Style Project Item
var styleProjectItem =
styleProjectItems.OfType<StyleProjectItem>().FirstOrDefault(s => s.Name == "ArcGIS 2D");
if (styleProjectItem == null)
{
return;
}
//Get the north arrow style item you need
var pointStyleItem =
styleProjectItem.SearchSymbols(StyleItemType.PointSymbol, "Circle 3").FirstOrDefault();
if (pointStyleItem == null)
{
return;
}
//Select a North arrow layout element
var layoutPointElement = layout.GetSelectedElements().FirstOrDefault();
if (layoutPointElement != null && layoutPointElement is GraphicElement ge)
{
if (layoutPointElement.CanApplyStyle(pointStyleItem))
{
//The magic happens here
//for Graphic Elements such as Point, Lines, Polys, text, preserve size.
ge.ApplyStyle(pointStyleItem, true);
}
}
});
}