Entity Color

Hi, I’m learning Aspose.Cad for Java. Can you tell me how to get the entity color(RGB)? And, What does ColorID 0, 7 and 256 mean?

@wlfei0502,
Hello.
Typically DWG/DXF drawings store the index of the color (ACI), table of which you may find e.g. here. 0 means ByBlock, so the color is stored in the block, that contains this entity. 256 means ByLayer, so the color is stored in the layer, assigned to this entity. Color 7 means white, but may be changed to black dependently on the background.
Drawing may store RGB colors too, in this case ColorValue (not ColorId) is used and HasValue inside it may be used to check whether ColorValue contains some number.

Thanks for your reply. I get it. But I have another question, if ColorValue contains some number, how to get RGB value by it?

@wlfei0502,
you can do:

int color = entity.getColorValue();

int b = (color)&0xFF;
int g = (color>>8)&0xFF;
int r = (color>>16)&0xFF;

or just

java.awt.Color c = new java.awt.Color(color);
System.out.println(“co.r=” + c.getRed());
System.out.println(“co.g=” + c.getGreen());
System.out.println(“co.b=” + c.getBlue());