AutoCAD indexed colors list

A little bit of code to export the list of Red, Green and Blue values for indexed AutoCAD colors:

[CommandMethod("DUMPCOLORS")]
public void DumpColors()
{
    using (var sw = new StreamWriter(@"C:\temp\acadColors.txt"))
    {
        sw.WriteLine(" I ; R ; G ; B ");
        for (short colorIndex = 1; colorIndex <= 255; colorIndex++)
        {
            using (Color color = Color.FromColorIndex(ColorMethod.ByAci, colorIndex))
            {
                sw.WriteLine("{0,3};{1,3};{2,3};{3,3}", colorIndex,
                    color.ColorValue.R, color.ColorValue.G, color.ColorValue.B);
            }
        }
    }
}

You can find the result file above:

Fichier attachéTaille
Plain text icon acadColors.txt4.25 KB

Etiquettes:

Ajouter un commentaire