A dotted ILineElement with a width greater than 1 is not dotted

03-20-2012 01:25 AM
New Contributor
Hello everyone,

I am trying to add a dotted line to mi map, and the code I am using is the following:

                //Define a polyline between the two given points 
                IPolyline polyline = new PolylineClass();
                polyline.FromPoint = from_point;
                polyline.ToPoint = to_point;

                //Define the color of the line (black)
                IRgbColor colorEsri = new RgbColorClass();
                colorEsri.Red = color.R;
                colorEsri.Green = color.G;
                colorEsri.Blue = color.B;

                //Create the final simple line, setting its properties
                ISimpleLineSymbol simpleLineSymbol = new SimpleLineSymbol();

                simpleLineSymbol.Color = colorEsri;
                simpleLineSymbol.Style = lineStyle;
                simpleLineSymbol.Width = width;

                //Create abd set the element that will contain the defined line
                //It's geometry will be the one of the polyline
                ILineElement element = new LineElementClass();
                element.Symbol = simpleLineSymbol as ILineSymbol;
                IElement lineElement = (IElement)element;
                lineElement.Geometry = (IGeometry)polyline;

When I add the line to the map, it is drawn correctly. But there is one case in which this is not working properly: if "lineStyle" is esriSimpleLineStyle.esriSLSDot and "width" is greater than 1, the line is not dotted, but a normal line. However, if "width" is equal to 1, then the line is perfectly dotted.

Does anyone know why I cannot create a dotted line with a width greater than 1?

Thank you very much in advance.
0 Kudos
2 Replies
Regular Contributor III
In my opinion, it's a bug.  The same thing happens in ArcMap if you use the drawing tools to create a line element and set the symbol to be a dashed line with a width greater than 1.  As far as I know, it's always been that way so I'm guessing ESRI doesn't have any plans to fix it.
0 Kudos
New Contributor II
Thanks for this post.  Yeah it still happens in ArcGIS 10.0 with the latest service pack.  Wonder if it ever got fixed in future versions.  Guess I'll find out soon enough.  Using width 1.0 suffices for now though.
0 Kudos