Setting_Line_Color

This code allows to set the color of all the lines within the document.

This short research was a "successful failure".

Something was found but it isn't what we hoped.

Our aim was to paint individually each line, but this is not allowed.

Anyway, its description and publication is a reporting duty.

 

As it can be seen, the code tried, without success, to paint only the selected lines.

 

Selection sel = Application.ActiveDocument.Selection;
            SelElementSet elems = sel.Elements;
            if (!elems.IsEmpty)
            {
                foreach (Element elem in elems)
                {
                    if (elem is ModelLine)
                    {
                        ModelLine curve = elem as ModelLine;
                        GraphicsStyle look = curve.LineStyle as GraphicsStyle;
                        Color color = Application.Create.NewColor();
 
                        // now I'm defining the RGB
                        color.Red = (byte)150;
                        color.Green = (byte)10;
                        color.Blue = (byte)10;
 
 
                        look.GraphicsStyleCategory.LineColor = color;
 
 
                    }
 
                    else
                    {
                        System.Windows.Forms.MessageBox.Show(" selected object must be a modelLine");
                    }
 
 
                }
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("you must select one or more lines");
            }
Gruppo di lavoro:
StefanoGuarnieri



Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer