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