ArcGIS Pro 3.4 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / SymbolFactory Class / ConstructStroke Method / ConstructStroke(CIMColor,Double,SimpleLineStyle) Method
ArcGIS.Core.CIM.CIMColor
The width of stroke to construct.
SimpleLineStyle
Example Version

ConstructStroke(CIMColor,Double,SimpleLineStyle) Method
Constructs a stroke of specific color, width and style.
Syntax

Parameters

color
ArcGIS.Core.CIM.CIMColor
width
The width of stroke to construct.
lineStyle
SimpleLineStyle

Return Value

Example
Create_polygon_env
//Create a polygon graphic using an envelope with simple line and fill styles.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build 2D envelope
  Coordinate2D env_ll = new Coordinate2D(1.0, 4.75);
  Coordinate2D env_ur = new Coordinate2D(3.0, 5.75);
  //At 2.x - Envelope env = EnvelopeBuilder.CreateEnvelope(env_ll, env_ur);
  Envelope env = EnvelopeBuilderEx.CreateEnvelope(env_ll, env_ur);

  //Set symbolology, create and add element to layout
  CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
    ColorFactory.Instance.BlueRGB, 2.0, SimpleLineStyle.DashDotDot);
  CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
    ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline);
  //At 2.x - GraphicElement polyElm =
  //            LayoutElementFactory.Instance.CreatePolygonGraphicElement(layout, env, polySym);
  //         polyElm.SetName("New Polygon");
  GraphicElement polyElm = ElementFactory.Instance.CreateGraphicElement(
    layout, env, polySym, "New Polygon");
});
Create_circle
//Create a circle graphic element using a simple line and fill styles.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build geometry
  Coordinate2D center = new Coordinate2D(2, 4);
  //At 2.x - EllipticArcBuilder eabCir = new EllipticArcBuilder(center, 0.5, esriArcOrientation.esriArcClockwise);
  var eabCir = new EllipticArcBuilderEx(center, 0.5, ArcOrientation.ArcClockwise);
  EllipticArcSegment cir = eabCir.ToSegment();

  //Set symbolology, create and add element to layout
  CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Dash);
  CIMPolygonSymbol circleSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.RedRGB, SimpleFillStyle.Solid, outline);
  //At 2.x - GraphicElement cirElm = LayoutElementFactory.Instance.CreateCircleGraphicElement(layout, cir, circleSym);
  //         cirElm.SetName("New Circle");

  var polyLine = PolylineBuilderEx.CreatePolyline(cir);
  GraphicElement cirElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, circleSym, "New Circle");
});
Create_ellipse
//Create an ellipse graphic with simple line and fill styles.

//Construct on the worker thread
await QueuedTask.Run(() =>
{
  //Build geometry
  Coordinate2D center = new Coordinate2D(2, 2.75);
  //At 2.x - EllipticArcBuilder eabElp = new EllipticArcBuilder(center, 0, 1, 0.45, esriArcOrientation.esriArcClockwise);
  var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, ArcOrientation.ArcClockwise);
  EllipticArcSegment ellipse = eabElp.ToSegment();

  //Set symbolology, create and add element to layout
  CIMStroke outline = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.GreenRGB, 2.0, SimpleLineStyle.Dot);
  CIMPolygonSymbol ellipseSym = SymbolFactory.Instance.ConstructPolygonSymbol(ColorFactory.Instance.GreyRGB, SimpleFillStyle.Vertical, outline);
  //At 2.x - GraphicElement elpElm = LayoutElementFactory.Instance.CreateEllipseGraphicElement(layout, ellipse, ellipseSym);
  //         elpElm.SetName("New Ellipse");

  var polyLine = PolylineBuilderEx.CreatePolyline(ellipse);
  GraphicElement elpElm = ElementFactory.Instance.CreateGraphicElement(layout, polyLine, ellipseSym, "New Ellipse");
});
Create rectangle graphic with simple symbology
//Create a simple 2D rectangle graphic and apply simple fill and
//outline symbols.

//Construct on the worker thread
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);
  //At 2.x - Envelope rec_env = EnvelopeBuilder.CreateEnvelope(rec_ll, rec_ur);
  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);

  //At 2.x - GraphicElement recElm =
  //           LayoutElementFactory.Instance.CreateRectangleGraphicElement(
  //                                                  layout, rec_env, polySym);
  //         recElm.SetName("New Rectangle");
  //
  GraphicElement recElm = ElementFactory.Instance.CreateGraphicElement(
    container, rec_env, polySym, "New Rectangle");
  //Or use Predefined shape
  GraphicElement recElm2 = ElementFactory.Instance.CreatePredefinedShapeGraphicElement(
                            container, 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);
Snippet Picture fill
/// <summary>
/// Constructs a picture fill with the specified parameters.
/// ![ConstructPictureFill](http://Esri.github.io/arcgis-pro-sdk/images/Symbology/ConstructPictureFill.png)
/// </summary>
/// <returns></returns>
private static Task<CIMPolygonSymbol> CreatePictureFillPolygonAsync()
{
  return QueuedTask.Run<CIMPolygonSymbol>(() =>
  {
    CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(110, 110, 110), 2.0, SimpleLineStyle.Solid);
    //picture
    var imgPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"Images\CaliforniaEmblem.png");
    var pictureFill = SymbolFactory.Instance.ConstructPictureFill(imgPath, 64);

    List<CIMSymbolLayer> symbolLayers = new()
    {
      outline,
      pictureFill
    };
    return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
  });
}
Snippet Animation water
/// <summary>
/// Constructs a water fill of specific color, waterbody size and wave strength. This fill can be used on polygon feature classes in a Scene view only.
/// ![ConstructWaterFill](https://github.com/ArcGIS/arcgis-pro-sdk/blob/master/Images/waterAnimation.gif)
/// </summary>
/// <returns></returns>
private static Task<CIMPolygonSymbol> CreateWaterFillPolygonAsync()
{
  return QueuedTask.Run<CIMPolygonSymbol>(() =>
  {
    CIMStroke outline = SymbolFactory.Instance.ConstructStroke(CIMColor.CreateRGBColor(49, 49, 49, 50.0), 2.0, SimpleLineStyle.Solid);
    var waterFill = SymbolFactory.Instance.ConstructWaterFill(CIMColor.CreateRGBColor(3, 223, 252), WaterbodySize.Large, WaveStrength.Rippled);
    List<CIMSymbolLayer> symbolLayers = new List<CIMSymbolLayer>
      {
                outline,
                waterFill
      };
    return new CIMPolygonSymbol() { SymbolLayers = symbolLayers.ToArray() };
  });
}
Requirements

Target Platforms: Windows 11, Windows 10

ArcGIS Pro version: 3 or higher.
See Also