Issue with AutoCAD Color Index
Posted: 26 Sep 2018, 19:29
Hello.
During an implementation I encountered an issue with some color indices.
The following code is being used to correctly retrieve color indices from entities, and with correct handling of the containing blocks, it's perfectly working on 16 different index values. However, for some reason, the code 255 is returned as 0 and the code 10 as 1 (in both cases the Color_type is "ByValue", so it can't be the case of the wrong block being fed as argument).
This issue was first identified with the version 11.2 (.NET 2.0) but only happened to the code 10 being returned as 1, after changing to the version 12.2 (both .NET 2.0 and 4.0) the issue could be verified on the code 255 aswell.
Any hint on what might be going wrong?
Thanks in advance,
Tiago Carvalho
During an implementation I encountered an issue with some color indices.
The following code is being used to correctly retrieve color indices from entities, and with correct handling of the containing blocks, it's perfectly working on 16 different index values. However, for some reason, the code 255 is returned as 0 and the code 10 as 1 (in both cases the Color_type is "ByValue", so it can't be the case of the wrong block being fed as argument).
Code: Select all
int GetColorCode(CADEntity cadEnt, CADBlock block)
{
int res = -1;
var objEntity = new ObjEntities(new CADEntityCollection() { cadEnt });
if (objEntity != null)
{
switch (objEntity.Color_type)
{
case "ByLayer":
res = CADImport.Export.SimpleCADtoDXF.DXFExport.ColorToDXF(cadEnt.Layer.Color);
break;
case "ByBlock":
if (block == null)
{
return -1;
}
res = CADImport.Export.SimpleCADtoDXF.DXFExport.ColorToDXF(block.Color);
break;
default:
res = CADImport.Export.SimpleCADtoDXF.DXFExport.ColorToDXF(cadEnt.Color);
break;
}
}
return res;
}
Any hint on what might be going wrong?
Thanks in advance,
Tiago Carvalho