ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.CIM Namespace / CIMStroke Class
Members Example

In This Topic
    CIMStroke Class
    In This Topic
    Represents a stroke which defines how line geometry or the outline of polygon geometry is drawn.
    Syntax
    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 Ellipse Graphic Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    Coordinate2D center = new Coordinate2D(2, 2.75);
    var eabElp = new EllipticArcBuilderEx(center, 0, 1, 0.45, 
                                           ArcOrientation.ArcClockwise);
    var 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);
    
    var poly = PolygonBuilderEx.CreatePolygon(
      PolylineBuilderEx.CreatePolyline(ellipse, AttributeFlags.AllAttributes));
    
    var elpElm = ElementFactory.Instance.CreateGraphicElement(
      container, poly, ellipseSym, "New Ellipse");
    Create Lasso Polygon, Freehand Element
    //Must be on QueuedTask.Run(() => { ...
    
    List<Coordinate2D> plyCoords = new List<Coordinate2D>();
    plyCoords.Add(new Coordinate2D(1, 1));
    plyCoords.Add(new Coordinate2D(1.25, 2));
    plyCoords.Add(new Coordinate2D(1.5, 1.1));
    plyCoords.Add(new Coordinate2D(1.75, 2));
    plyCoords.Add(new Coordinate2D(2, 1.1));
    plyCoords.Add(new Coordinate2D(2.25, 2));
    plyCoords.Add(new Coordinate2D(2.5, 1.1));
    plyCoords.Add(new Coordinate2D(2.75, 2));
    plyCoords.Add(new Coordinate2D(3, 1));
    Polygon poly = PolygonBuilderEx.CreatePolygon(plyCoords);
    
    //Set symbolology, create and add element to layout
    CIMStroke outline = SymbolFactory.Instance.ConstructStroke(
                ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid);
    CIMPolygonSymbol polySym = SymbolFactory.Instance.ConstructPolygonSymbol(
             ColorFactory.Instance.RedRGB, SimpleFillStyle.ForwardDiagonal, outline);
    
    ElementFactory.Instance.CreateGraphicElement(
      container, poly, polySym, "New Lasso");
    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 symbolology, 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);
    
    How to construct a line symbol from a stroke
    CIMStroke stroke = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.BlackRGB, 2.0);
    CIMLineSymbol lineSymbolFromStroke = SymbolFactory.Instance.ConstructLineSymbol(stroke);
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CIM.CIMObject
          ArcGIS.Core.CIM.CIMSymbolLayer
             ArcGIS.Core.CIM.CIMStroke
                ArcGIS.Core.CIM.CIMGradientStroke
                ArcGIS.Core.CIM.CIMPictureStroke
                ArcGIS.Core.CIM.CIMSolidStroke

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also