Try this, it uses AutoCAD to translate its colour index to RGB - and can give the closest matching Colour Index (between 1 and 255) for any given RGB tuple:
Code:
(vl-load-com)
(defun AC-CI-2-RGB (CI / obj RGB)
;; Get a color object from the current layer
(setq obj (vlax-ename->vla-object (tblobjname "LAYER" (getvar "CLAYER"))))
(setq obj (vla-get-TrueColor obj))
(vla-put-ColorIndex obj CI)
(setq RGB (list (vla-get-Red obj) (vla-get-Green obj) (vla-get-Blue obj)))
)
(defun RGB-2-AC-CI (RGB / obj CI)
;; Get a color object from the current layer
(setq obj (vlax-ename->vla-object (tblobjname "LAYER" (getvar "CLAYER"))))
(setq obj (vla-get-TrueColor obj))
(vla-SetRGB obj (car RGB) (cadr RGB) (caddr RGB))
(setq CI (vla-get-ColorIndex obj))
)
(defun Write-CI-RGB ($file / CI)
(setq CI 1)
(while (< CI 256)
(if $file
(write-line (strcat (itoa CI) " = " (vl-princ-to-string (AC-CI-2-RGB CI))) $file)
(princ (strcat "\n" (itoa CI) " = " (vl-princ-to-string (AC-CI-2-RGB CI))))
)
(setq CI (1+ CI))
)
)
Example use: type (Write-CI-RGB "c:\\AC-RGB.TXT") at the command line. It will then save all AC colours to a file, together with their RGB values in decimal 256 format.
To get a particular colour index's RGB (e.g. 253) type (AC-CI-2-RGB 253) at the command line.It'll show the RGB value of (173 173 173).
To get the closest matching CI of a RGB value type (RGB-2-AC-CI '(170 175 169)) at the command line.It'll show the CI value of 253, even though it's not exact it's the closest match.