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

In This Topic
    CIMLineSymbol Class
    In This Topic
    Represents a line symbol which is used to draw polyline features or graphics.
    Object Model
    CIMLineSymbol ClassCIMLineSymbol ClassCIMLineSymbol Class
    Syntax
    Example
    Create Lasso Line, Freehand Graphic Element
    //Must be on QueuedTask.Run(() => { ...
    
    //Build geometry
    List<Coordinate2D> plCoords = new List<Coordinate2D>();
    plCoords.Add(new Coordinate2D(1.5, 10.5));
    plCoords.Add(new Coordinate2D(1.25, 9.5));
    plCoords.Add(new Coordinate2D(1, 10.5));
    plCoords.Add(new Coordinate2D(0.75, 9.5));
    plCoords.Add(new Coordinate2D(0.5, 10.5));
    plCoords.Add(new Coordinate2D(0.5, 1));
    plCoords.Add(new Coordinate2D(0.75, 2));
    plCoords.Add(new Coordinate2D(1, 1));
    Polyline linePl = PolylineBuilderEx.CreatePolyline(plCoords);
    
    //Set symbolology, create and add element to layout
    CIMLineSymbol lineSym = SymbolFactory.Instance.ConstructLineSymbol(
              ColorFactory.Instance.BlackRGB, 2.0, SimpleLineStyle.Solid);
    //var graphic = GraphicFactory.Instance.CreateShapeGraphic(linePl, lineSym);
    
    var ge = ElementFactory.Instance.CreateGraphicElement(
                            container, linePl, lineSym, "New Freehand");
    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");
    });
    How to construct a line symbol of specific color, size and line style
    CIMLineSymbol lineSymbol = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 4.0, SimpleLineStyle.Solid);
    
    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);
    
    How to construct a multilayer line symbol with circle markers on the line ends
    //These methods must be called within the lambda passed to QueuedTask.Run
    var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0);
    var markerCircle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle);
    markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices()
    {
      AngleToLine = true,
      PlaceOnEndPoints = true,
      Offset = 0
    };
    var lineSymbolWithCircles = new CIMLineSymbol()
    {
      SymbolLayers = new CIMSymbolLayer[2] { markerCircle, lineStrokeRed }
    };
    
    How to construct a multilayer line symbol with circle markers on the line ends
    //These methods must be called within the lambda passed to QueuedTask.Run
    var lineStrokeRed = SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 4.0);
    var markerCircle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Circle);
    markerCircle.MarkerPlacement = new CIMMarkerPlacementOnVertices()
    {
      AngleToLine = true,
      PlaceOnEndPoints = true,
      Offset = 0
    };
    var lineSymbolWithCircles = new CIMLineSymbol()
    {
      SymbolLayers = new CIMSymbolLayer[2] { markerCircle, lineStrokeRed }
    };
    
    How to construct a multilayer line symbol with an arrow head on the end
    //These methods must be called within the lambda passed to QueuedTask.Run
    var markerTriangle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Triangle);
    markerTriangle.Rotation = -90; // or -90
    markerTriangle.MarkerPlacement = new CIMMarkerPlacementOnLine() { AngleToLine = true, RelativeTo = PlacementOnLineRelativeTo.LineEnd };
    
    var lineSymbolWithArrow = new CIMLineSymbol()
    {
      SymbolLayers = new CIMSymbolLayer[2] { markerTriangle,
                  SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2)
              }
    };
    
    How to construct a multilayer line symbol with an arrow head on the end
    //These methods must be called within the lambda passed to QueuedTask.Run
    var markerTriangle = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12, SimpleMarkerStyle.Triangle);
    markerTriangle.Rotation = -90; // or -90
    markerTriangle.MarkerPlacement = new CIMMarkerPlacementOnLine() { AngleToLine = true, RelativeTo = PlacementOnLineRelativeTo.LineEnd };
    
    var lineSymbolWithArrow = new CIMLineSymbol()
    {
      SymbolLayers = new CIMSymbolLayer[2] { markerTriangle,
                  SymbolFactory.Instance.ConstructStroke(ColorFactory.Instance.RedRGB, 2)
              }
    };
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.CIM.CIMObject
          ArcGIS.Core.CIM.CIMSymbol
             ArcGIS.Core.CIM.CIMMultiLayerSymbol
                ArcGIS.Core.CIM.CIMLineSymbol

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also