For any Entity in AutoCAD (eg line, circle, block, etc), you can use the .Color property (for .NET in-process API):
Entity ent = // get the entity here;
Autodesk.AutoCAD.Colors.Color c = ent.Color;
int[] rgb = new int[] { c.Red, c.Green, c.Blue };
As you mentioned out-of-process COM/ActiveX, you can try something similar:
AcadEntity ent = // get the entity here;
int[] rgb = new int[] { ent.TrueColor.Red, ent.TrueColor.Green, ent.TrueColor.Blue };
The reply I gave on Autodesk discussion group.
AcadAcCmColor color = new AcadAcCmColor();
int index = 0;
if (colorName.ToUpper() == "BYBLOCK")
{
color.ColorIndex = AcColor.acByBlock;
}
else if (colorName.ToUpper() == "BYLAYER")
{
color.ColorIndex = AcColor.acByLayer;
}
else if (int.TryParse(colorName, out index))
{
color.ColorIndex = (AcColor)index;
}
else if (colorName.ToUpper().StartsWith("RGB:"))
{
string[] rgb = colorName.Substring(4).Split(',');
color.SetRGB(int.Parse(rgb[0]), int.Parse(rgb[1]), int.Parse(rgb[2]));
}
else
{
string[] bookColor = colorName.Split('$');
color.SetColorBookColor(bookColor[0], bookColor[1]);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.