Author Topic: Set color from Pantone color book  (Read 913 times)

0 Members and 1 Guest are viewing this topic.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Set color from Pantone color book
« on: May 25, 2012, 07:58:57 AM »
Code: [Select]
       [CommandMethod("TestColorPantone","tcp", CommandFlags.Modal | CommandFlags.UsePickSet | CommandFlags.Redraw)]
        public static void TestPantoneColorBook()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;

            Editor ed = doc.Editor;

            Database db = doc.Database;

            PromptEntityOptions optEnt = new PromptEntityOptions("\nSelect object: ");

            optEnt.SetRejectMessage("\nSelect object only!");

            optEnt.AddAllowedClass(typeof(Entity), false);

            PromptEntityResult res = ed.GetEntity(optEnt);

            if (res.Status != PromptStatus.OK) return;

            ObjectId id = res.ObjectId;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite, false);

                Entity ent = tr.GetObject(id, OpenMode.ForWrite) as Entity;

                // Change color from PANTONE color book, e.g.:

                // ent.Color = Color.FromNames("PANTONE Magenta 2582 C","PANTONE(R) solid coated");

                ent.Color = Color.FromNames("RAL 230 30 15", "RAL DESIGN");// etc...

                tr.Commit();

            }
        }

~'J'~