How to make a cartographic line symbol


Summary This topic shows the necessary steps to create a dashed cartographic line symbol.

Making a cartographic line symbol

Cartographic line symbols allow you to create either solid unbroken lines, or lines that consist of a series of marks and gaps to create a variety of dashed symbols. The Cap property is used to control the appearance of start and end nodes. The Join property can control how line bends display.
Do the following steps to make a cartographic line symbol:
  1. Create a cartographic line symbol and set its properties.
  2. Create an ILineProperties object to set additional properties, such as offsets and dash patterns.
  3. Add the mark and gap patterns into the template.
  4. Set the cartographic line properties.
  5. Color the line red.
See the following code example that shows the creation of a dashed line symbol, which consists of a long dash followed by three short dashes (dots):
[VB.NET]
Public Sub CartographicLineSymbol()
    
    ' Make a new cartographic line symbol and set its properties.
    Dim cartographicLineSymbolCls As ESRI.ArcGIS.Display.ICartographicLineSymbol = New ESRI.ArcGIS.Display.CartographicLineSymbolClass
    
    ' To set additional properties like offsets and dash patterns, create an ILineProperties object.
    Dim lineProperties As ESRI.ArcGIS.Display.ILineProperties = CType(cartographicLineSymbolCls, ESRI.ArcGIS.Display.ILineProperties) ' Explicit Cast
    lineProperties.Offset = 0
    
    ' Do a template for the pattern of marks and gaps.
    Dim pttrn(6) As System.Double
    pttrn(0) = 0
    pttrn(1) = 7
    pttrn(2) = 1
    pttrn(3) = 1
    pttrn(4) = 1
    pttrn(5) = 0
    
    Dim templateCls As ESRI.ArcGIS.Display.ITemplate = New ESRI.ArcGIS.Display.TemplateClass
    templateCls.Interval = 1
    
    ' Add the mark and gap patterns into the template.
    Dim jx As System.Int32 = 0
    Dim ix As System.Int32
    For ix = 1 To 3
        templateCls.AddPatternElement(pttrn(jx), pttrn(jx + 1))
        jx = jx + 2
    Next ix
    
    lineProperties.Template = templateCls
    
    ' Set the cartographic line properties.
    cartographicLineSymbolCls.Width = 2
    cartographicLineSymbolCls.Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt
    cartographicLineSymbolCls.Join = ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSBevel
    
    ' Make the line red.
    Dim rgbColorCls As ESRI.ArcGIS.Display.IRgbColor = New ESRI.ArcGIS.Display.RgbColorClass
    rgbColorCls.Red = 255
    rgbColorCls.Green = 0
    rgbColorCls.Blue = 0
    cartographicLineSymbolCls.Color = rgbColorCls
    
End Sub
[C#]
public void CartographicLineSymbol()
{
    // Make a new cartographic line symbol and set its properties.
    ESRI.ArcGIS.Display.ICartographicLineSymbol cartographicLineSymbolCls = new
        ESRI.ArcGIS.Display.CartographicLineSymbolClass();

    // To set additional properties like offsets and dash patterns, create an ILineProperties object.
    ESRI.ArcGIS.Display.ILineProperties lineProperties = (
        (ESRI.ArcGIS.Display.ILineProperties)(cartographicLineSymbolCls));
    lineProperties.Offset = 0;

    // Do a template for the pattern of marks and gaps.
    System.Double[] pttrn = new System.Double[6];
    pttrn[0] = 0;
    pttrn[1] = 7;
    pttrn[2] = 1;
    pttrn[3] = 1;
    pttrn[4] = 1;
    pttrn[5] = 0;

    ESRI.ArcGIS.Display.ITemplate templateCls = new
        ESRI.ArcGIS.Display.TemplateClass();
    templateCls.Interval = 1;

    // Add the mark and gap patterns into the template.
    System.Int32 jx = 0;
    System.Int32 ix;
    for (ix = 1; ix <= 3; ix++)
    {
        templateCls.AddPatternElement(pttrn(jx), pttrn(jx + 1));
        jx = jx + 2;
    }

    lineProperties.Template = templateCls;

    //Set the cartographic line properties.
    cartographicLineSymbolCls.Width = 2;
    cartographicLineSymbolCls.Cap = ESRI.ArcGIS.Display.esriLineCapStyle.esriLCSButt;
    cartographicLineSymbolCls.Join =
        ESRI.ArcGIS.Display.esriLineJoinStyle.esriLJSBevel;

    // Make the line red.
    ESRI.ArcGIS.Display.IRgbColor rgbColorCls = new
        ESRI.ArcGIS.Display.RgbColorClass();
    rgbColorCls.Red = 255;
    rgbColorCls.Green = 0;
    rgbColorCls.Blue = 0;
    cartographicLineSymbolCls.Color = rgbColorCls;
}


See Also:

How to make a character marker symbol
How to make a gradient fill symbol
How to make a line callout
How to make a line fill symbol
How to make a picture marker symbol
Creating custom symbols
Creating other kinds of custom symbols
How to make different types of colors and color ramps




Development licensing Deployment licensing
ArcView ArcView
ArcEditor ArcEditor
ArcInfo ArcInfo
Engine Developer Kit Engine Runtime