ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SymbolExtensionMethods Class / SetSize Method
ArcGIS.Core.CIM.CIMSymbol
System.Double
Example

In This Topic
    SetSize Method
    In This Topic
    Sets size of a symbol.
    Syntax
    public static void SetSize( 
       CIMSymbol symbol,
       double size
    )
    Public Shared Sub SetSize( _
       ByVal symbol As CIMSymbol, _
       ByVal size As Double _
    ) 

    Parameters

    symbol
    ArcGIS.Core.CIM.CIMSymbol
    size
    System.Double
    Example
    Create Line Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    List<Coordinate2D> plCoords = new List<Coordinate2D>();
    plCoords.Add(new Coordinate2D(1, 8.5));
    plCoords.Add(new Coordinate2D(1.66, 9));
    plCoords.Add(new Coordinate2D(2.33, 8.1));
    plCoords.Add(new Coordinate2D(3, 8.5));
    Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords);
    
    //Reference a line symbol in a style
    var ProjectStyles = Project.Current.GetItems<StyleProjectItem>();
    StyleProjectItem style = ProjectStyles.First(x => x.Name == "ArcGIS 2D");
    var symStyle = style.SearchSymbols(StyleItemType.LineSymbol, "Line with 2 Markers")[0];
    CIMLineSymbol lineSym = symStyle.Symbol as CIMLineSymbol;
    lineSym.SetSize(20);
    
    //Set symbolology, create and add element to layout
    //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid);
    ElementFactory.Instance.CreateGraphicElement(
      container, linePl, lineSym, "New Line");
    
    Create Point Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D coord2D = new Coordinate2D(2.0, 10.0);
    
    //Reference a point symbol in a style
    StyleProjectItem stylePrjItm = Project.Current.GetItems<StyleProjectItem>()
             .FirstOrDefault(item => item.Name == "ArcGIS 2D");
    SymbolStyleItem symStyleItm = stylePrjItm.SearchSymbols(
                          StyleItemType.PointSymbol, "City Hall")[0];
    CIMPointSymbol pointSym = symStyleItm.Symbol as CIMPointSymbol;
    pointSym.SetSize(50);
    
    var elemInfo = new ElementInfo()
    {
      CustomProperties = new List<CIMStringMap>() {
         new CIMStringMap() { Key = "Key1", Value = "Value1"},
         new CIMStringMap() { Key = "Key2", Value = "Value2"}
       },
      Anchor = Anchor.TopRightCorner,
      Rotation = 45.0
    };
    
    var graphic = GraphicFactory.Instance.CreateSimpleGraphic(
                                  coord2D.ToMapPoint(), pointSym);
    
    ElementFactory.Instance.CreateGraphicElement(
      container, graphic, "New Point", true, elemInfo);
    
    Create point graphic with symbology
    //Create a simple 2D point graphic and apply an existing point style item as the symbology.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build 2D point geometry  
      Coordinate2D coord2D = new Coordinate2D(2.0, 10.0);
    
      //(optionally) Reference a point symbol in a style
      StyleProjectItem ptStylePrjItm = Project.Current.GetItems<StyleProjectItem>()
                                    .FirstOrDefault(item => item.Name == "ArcGIS 2D");
      SymbolStyleItem ptSymStyleItm = ptStylePrjItm.SearchSymbols(
                                             StyleItemType.PointSymbol, "City Hall")[0];
      CIMPointSymbol pointSym = ptSymStyleItm.Symbol as CIMPointSymbol;
      pointSym.SetSize(50);
    
      //Set symbolology, create and add element to layout
    
      //An alternative simple symbol is also commented out below.
      //This would elminate the four optional lines of code above that
      //reference a style.
    
      //CIMPointSymbol pointSym = SymbolFactory.Instance.ConstructPointSymbol(
      //                  ColorFactory.Instance.RedRGB, 25.0, SimpleMarkerStyle.Star);  
      //At 2.x - GraphicElement ptElm =
      //                    LayoutElementFactory.Instance.CreatePointGraphicElement(
      //                                        layout, coord2D, pointSym);
    
      GraphicElement ptElm = ElementFactory.Instance.CreateGraphicElement(
                                     container, coord2D.ToMapPoint(), pointSym);
      ptElm.SetName("New Point");
    });
    Create line graphic with symbology
    //Create a simple 2D line graphic and apply an existing line
    //style item as the symbology.
    
    //Construct on the worker thread
    await QueuedTask.Run(() =>
    {
      //Build 2d line geometry
      List<Coordinate2D> plCoords = new List<Coordinate2D>();
      plCoords.Add(new Coordinate2D(1, 8.5));
      plCoords.Add(new Coordinate2D(1.66, 9));
      plCoords.Add(new Coordinate2D(2.33, 8.1));
      plCoords.Add(new Coordinate2D(3, 8.5));
      //At 2.x - Polyline linePl = PolylineBuilder.CreatePolyline(plCoords);
      Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords);
    
      //(optionally) Reference a line symbol in a style
      StyleProjectItem lnStylePrjItm = Project.Current.GetItems<StyleProjectItem>()
                                    .FirstOrDefault(item => item.Name == "ArcGIS 2D");
      SymbolStyleItem lnSymStyleItm = lnStylePrjItm.SearchSymbols(
                                    StyleItemType.LineSymbol, "Line with 2 Markers")[0];
      CIMLineSymbol lineSym = lnSymStyleItm.Symbol as CIMLineSymbol;
      lineSym.SetSize(20);
    
      //Set symbolology, create and add element to layout
    
      //An alternative simple symbol is also commented out below.
      //This would elminate the four optional lines of code above that
      //reference a style.
      //
      //CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(
      //         ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid);  
      //At 2.x - GraphicElement lineElm =
      //        LayoutElementFactory.Instance.CreateLineGraphicElement(
      //                                            layout, linePl, lineSym);
    
      GraphicElement lineElm = ElementFactory.Instance.CreateGraphicElement(
                                                  container, linePl, lineSym);
      lineElm.SetName("New Line");
    });
    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also