Page 1 of 1

Issue with AutoCAD Color Index

Posted: 26 Sep 2018, 19:29
by tiagocarvalho
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).

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;
        }
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

Re: Issue with AutoCAD Color Index

Posted: 26 Sep 2018, 23:20
by support
Hello Tiago,

It appears that a ColorToDXF function cannot distinguish AutoCAD Color Index (ACI) pallete colors which have the same RGB equivalents. For example:

ACI #1 and ACI #10 = RGB (255, 0, 0) - Red color,
ACI #2 and ACI #50 = RGB (255, 255, 0) - Yellow color.

As for the color with index 255, it can be White or Grey, depending on the background color. The ColorToDXF function worked incorrectly with the given color also in the previous versions. The fix for this issue will be available in the next builds.

Mikhail

Re: Issue with AutoCAD Color Index

Posted: 02 Oct 2018, 19:32
by support
Tiago,

The given issue has been resolved. To get a CADImport.dll build with the bug fix, please contact us at the Technical Support e-mail.

Mikhail