Example #1
0
        public static void ChangeEntColour()
        {
            //
            // Get some user input:
            //
            _AcEd.Editor             ed  = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
            _AcEd.PromptEntityResult res = ed.GetEntity("Select an entity to change its colour:");

            if (res.Status == _AcEd.PromptStatus.OK)
            {
                var entId = res.ObjectId;

                var db = _AcDb.HostApplicationServices.WorkingDatabase;
                using (var tr = db.TransactionManager.StartTransaction()) {
                    var ent = tr.GetObject(entId, Teigha.DatabaseServices.OpenMode.ForWrite) as _AcDb.Entity;

                    //
                    // Ask the user for the new colour number
                    //
                    _AcEd.PromptIntegerResult intres = ed.GetInteger("\nEnter new colorindex integer (0 -> 255): ");

                    if (intres.Status == _AcEd.PromptStatus.OK)
                    {
                        ent.ColorIndex = intres.Value;
                    }
                    tr.Commit();
                }
            }
        }