Make a Color Current Through the Database (.NET)

This example sets a color current through the Database object with the Cecolor property.

C# Example

using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Colors;
 
[CommandMethod("SetColorCurrent")]
public static void SetColorCurrent()
{
    // Get the current document
    Document acDoc = Application.DocumentManager.MdiActiveDocument;
 
    // Set the current color
    acDoc.Database.Cecolor = Color.FromColorIndex(ColorMethod.ByLayer, 256);
}