NP CAD Page | Articles | Download | Russian

N.Poleshchuk. The AcCmColor Class

Starting from version 2000 color got opportunity to store 16.7 million values from the True Color palette. 62 DXF code receives old-fashion main integer values (from 1 till 255), special values 0 (ByBlock) and 256 (ByLayer). Further value 257 (ByEntity) was added. For the True Color palette elements there is 420 DXF code is applied. Its value is a 24 bit number formed from the R (red), G (green), B (blue) components by the formula:

mycol = 164 * R + 162 * G + B,

where each of integer R, G, and B may get values from 0 till 255. Besides as a color value, 432 DXF code may be used for color name from the color book, e.g. "RAL 1002".

To store such an extensive set of values AcCmColor class was created. This class object can keep any of the mentioned color values. During AutoCAD installation this class is being registered in Windows, and object of the class may be created by the following scheme:

(setq mycol (vlax-GetInterfaceObject (vlax-get-acad-object) "AutoCAD.AcCmColor.18"))


For reference, we have in other languages:
VBA
Dim color As New AcadAcCmColor
Set color = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.18")

C++ (ObjectARX)
AcCmColor m_color;
C# (.NET)
Autodesk.AutoCAD.Colors.Color m_color;
Visual Basic (.NET)
Dim m_color As Autodesk.AutoCAD.Colors.Color


The AcCmColor color has version number to be written after "AutoCAD.AcCmColor." when calling GetInterfaceMethod:
15 - for AutoCAD 2000-2002,
16 - for AutoCAD 2004-2006,
17 - for AutoCAD 2007-2009,
18 - for AutoCAD 2010-2012.

There are three methods in the AcCmColor class definition:

  • SetColorBookColor - setting color by the name from the color book;
  • SetNames - setting color name string and color book string;
  • SetRGB - setting color by R, G, B components.
    The class has eight properties:
  • Blue - color blue (B) component value;
  • BookName - color book name;
  • ColorIndex - color name (if you use method of setting by color index from 0 till 256);
  • ColorMethod - method of setting color (integer from 192 till 200, e.g. acColorMethodByRGB = 194, acColorMethodByACI = 195);
  • ColorName - color name;
  • EntityColor - color number as a long (32-bit) integer number (if you use method of setting by R, G, B components);
  • Green - color green (G) component value;
  • Red - color red (R) component value.

    Examples of setting color value:
    (vla-SetRGB mycol 83 127 19)
    (vla-put-ColorIndex mycol 5)

    Example of modifying last entity color to mycol:
    (vla-put-TrueColor (vlax-ename->vla-object (entlast)) mycol)

    On work end one should free memory occupied by the object:
    (vlax-release-object mycol)


    Note. Another way for creation of AcCmColor object:
    (setq yourcol (vlax-create-object "AutoCAD.AcCmColor.18"))

    NP CAD Page | Articles | Download | Russian