Convert Autocad Color Index TO/FROM ARGB

Convert Autocad Color Index TO/FROM ARGB

Anonymous
Not applicable
3,963 Views
2 Replies
Message 1 of 3

Convert Autocad Color Index TO/FROM ARGB

Anonymous
Not applicable

Hi, i need store Layers colors outside Autocad and return a new color.

 

I want a example to convert aci to/from System.Drawing.Color ARGB.

 

 

thanks

0 Likes
Accepted solutions (1)
3,964 Views
2 Replies
Replies (2)
Message 2 of 3

rkmcswain
Mentor
Mentor
Does this help any? Check the link in post 4 also.

http://forums.autodesk.com/t5/net/problems-with-rgb-and-color-index/td-p/3715706

R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

I try solutions at this post, but no one work well to me.

I implement this code to convert to System.drawing.color, and send to external routines.

 

private System.Drawing.Color AcadColorAciToDrawingColor(Autodesk.AutoCAD.Colors.Color color)
{
byte aci = Convert.ToByte(color.ColorIndex);
int aRGB = EntityColor.LookUpRgb(aci);
byte[] ch = BitConverter.GetBytes(aRGB);
if (!BitConverter.IsLittleEndian) {
Array.Reverse(ch);
}
int r = ch[2];
int g = ch[1];
int b = ch[0];

return System.Drawing.Color.FromArgb(r,g, b);
}

 

thanks