[Cloud Design]
Pubblicata su [Cloud Design] (http://design.rootiers.it)

Home > Setting_Line_Color

Setting_Line_Color

published by StefanoGuarnieri on Mar, 15/02/2011 - 02:03

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");
            }
Tecniche Parametriche [1]
RevitVSTA [2]
C# [3]
macro [4]
Revit2010 [5]
Realizzato con Drupal

URL di origine: http://design.rootiers.it/node/633

Links
[1] http://design.rootiers.it/taxonomy/term/4
[2] http://design.rootiers.it/taxonomy/term/96
[3] http://design.rootiers.it/taxonomy/term/97
[4] http://design.rootiers.it/taxonomy/term/98
[5] http://design.rootiers.it/taxonomy/term/99