ArcGIS Pro 3.8 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / ISymbolFactory Interface / ConstructPolygonSymbol Method / ConstructPolygonSymbol(CIMColor,SimpleFillStyle,CIMStroke) Method
ArcGIS.Core.CIM.CIMColor
SimpleFillStyle
ArcGIS.Core.CIM.CIMStroke
Example

In This Topic
    ConstructPolygonSymbol(CIMColor,SimpleFillStyle,CIMStroke) Method
    In This Topic
    Constructs a polygon symbol of specific color, style and outline.
    Syntax
    Overloads Function ConstructPolygonSymbol( _
       ByVal color As CIMColor, _
       ByVal fillStyle As SimpleFillStyle, _
       ByVal outline As CIMStroke _
    ) As CIMPolygonSymbol

    Parameters

    color
    ArcGIS.Core.CIM.CIMColor
    fillStyle
    SimpleFillStyle
    outline
    ArcGIS.Core.CIM.CIMStroke

    Return Value

    Remarks
    Passing null for outline will create a polygon symbol without an outline.
    Example
    Create rectangle graphic with simple symbology
    {
      //Create a simple 2D rectangle graphic and apply simple fill and
      //outline symbols.
    
      await QueuedTask.Run(() =>
      {
    
      //Build 2D envelope geometry
      Coordinate2D rec_ll = new Coordinate2D(1.0, 4.75);
      Coordinate2D rec_ur = new Coordinate2D(3.0, 5.75);
    
      Envelope rec_env = EnvelopeBuilderEx.CreateEnvelope(rec_ll, rec_ur);
    
      //Set symbology, create and add element to layout
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
        ColorFactory.Instance.BlackRGB, 5.0, SimpleLineStyle.Solid);
      CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
        ColorFactory.Instance.GreenRGB, SimpleFillStyle.DiagonalCross, outline);
    
    
      GraphicElement recElm = ElementFactory.Instance.CreateGraphicElement(
        layout, rec_env, polySym, "New Rectangle");
      //Or use Predefined shape
      GraphicElement recElm2 = ElementFactory.Instance.CreatePredefinedShapeGraphicElement(
                                layout, PredefinedShape.Rectangle, rec_env, polySym,
                                "New Rectangle2");
      });
    }
    How to construct a polygon symbol of specific color, fill style and outline
    {
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);
      CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline);
    }
    How to construct a polygon symbol without an outline
    {
      CIMPolygonSymbol fillWithoutOutline = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, null);
    }
    Simple Renderer for a Polygon feature layer.
    /// <summary>
    /// Renders a Polygon feature layer using a single symbol.
    /// ![Simple Renderer for Polygon features](https://ArcGIS.github.io/arcgis-pro-sdk/images/Renderers/simple-polygon.png)
    /// </summary>
    {
      //Check feature layer name
      //Code works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data
      var featureLayer = activeMap.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(f => f.Name == "USDemographics");
      if (featureLayer == null)
      {
        MessageBox.Show("This renderer works with the USDemographics feature layer available with the ArcGIS Pro SDK Sample data", "Data missing");
      }
      //Creating a polygon with a red fill and blue outline.
      CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
            ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.Solid);
      CIMPolygonSymbol fillWithOutline = SymbolFactory.Instance.ConstructPolygonSymbol(
            ColorFactory.Instance.CreateRGBColor(255, 190, 190), SimpleFillStyle.Solid, outline);
      await QueuedTask.Run(() =>
      {
        //Get the layer's current renderer
        CIMSimpleRenderer renderer = featureLayer.GetRenderer() as CIMSimpleRenderer;
    
        //Update the symbol of the current simple renderer
        renderer.Symbol = fillWithOutline.MakeSymbolReference();
    
        //Update the feature layer renderer
        featureLayer.SetRenderer(renderer);
      });
    }
    Procedural Symbol
    /// <summary>
    /// Create a procedural symbol that can be applied to a polygon building footprint layer
    /// ![ProceduralSymbol](https://ArcGIS.github.io/arcgis-pro-sdk/images/Symbology/polygon-procedural.png)
    /// Note: The rule package used in this method can be obtained from the Sample Data included in the arcgis-pro-sdk-community-samples repository.
    /// </summary>
    {
      //Note: Run withing QueuedTask
      string _rulePkgPath = @"C:\Data\RulePackages\Venice_2014.rpk";
      //Polygon symbol to hold the procedural layer
      var proceduralSymbol = SymbolFactory.Instance.ConstructPolygonSymbol();
    
      //Array of layers to hold a procedural symbol layer
      CIMSymbolLayer[] proceduralSymbolLyr =
            {
                new CIMProceduralSymbolLayer()
                {
                    PrimitiveName = "Venice Rule package 2014",
                    RulePackage = _rulePkgPath,
                    RulePackageName = "Venice_2014",
                }
      };
      proceduralSymbol.SymbolLayers = proceduralSymbolLyr;
      //To apply the symbol to a polygon feature layer
      //var renderer = theLayer.GetRenderer() as CIMSimpleRenderer;
      //renderer.Symbol = proceduralSymbol.MakeSymbolReference();
      //theLayer.SetRenderer(renderer);
    }
    Requirements

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

    ArcGIS Pro version: 3.0 or higher.
    See Also