KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: 4D Color constants to RGB HEX
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: July 13, 2020

The command OBJECT SET COLOR has become deprecated in 4Dv18. The suggested replacement is to use OBJECT SET RGB COLORS. Below is a utility method that will convert a 4D color constant to the RGB HEX value.

// Method Name: Util_4DColorToHex
C_LONGINT($1)

ARRAY LONGINT($t_ColorTable;255)

$t_ColorTable{0}:=0x00FFFFFF
$t_ColorTable{1}:=0x00FFFF00
$t_ColorTable{2}:=0x00FF6600
$t_ColorTable{3}:=0x00EE0000
$t_ColorTable{4}:=0x00FF0099
$t_ColorTable{5}:=0x00000099
$t_ColorTable{6}:=0x000000FF
$t_ColorTable{7}:=0x000099FF
$t_ColorTable{8}:=0x0000BB00
$t_ColorTable{9}:=0x00009900
$t_ColorTable{10}:=0x00663300
$t_ColorTable{11}:=0x00444444
$t_ColorTable{12}:=0x00DDDDDD
$t_ColorTable{13}:=0x00996600
$t_ColorTable{14}:=0x00AAAAAA
$t_ColorTable{15}:=0x00000000
$t_ColorTable{16}:=0x00FF005E
$t_ColorTable{17}:=0x00FF0456
$t_ColorTable{18}:=0x00FF0048
$t_ColorTable{19}:=0x00FF004B
$t_ColorTable{20}:=0x00FF0032
$t_ColorTable{21}:=0x00FF0027
$t_ColorTable{22}:=0x00FF001C
$t_ColorTable{23}:=0x00FF0011
$t_ColorTable{24}:=0x00FF0006
$t_ColorTable{25}:=0x00FF0400
$t_ColorTable{26}:=0x00FF0F00
$t_ColorTable{27}:=0x00FF1A00
$t_ColorTable{28}:=0x00FF2500
$t_ColorTable{29}:=0x00FF3000
$t_ColorTable{30}:=0x00FF3B00
$t_ColorTable{31}:=0x00FF4600
$t_ColorTable{32}:=0x00FF4D00
$t_ColorTable{33}:=0x00FF5400
$t_ColorTable{34}:=0x00FF5B00
$t_ColorTable{35}:=0x00FF6200
$t_ColorTable{36}:=0x00FF6900
$t_ColorTable{37}:=0x00FF7203
$t_ColorTable{38}:=0x00FF7C04
$t_ColorTable{39}:=0x00FF8202
$t_ColorTable{40}:=0x00FF8A06
$t_ColorTable{41}:=0x00FF9203
$t_ColorTable{42}:=0x00FF9902
$t_ColorTable{43}:=0x00FFA003
$t_ColorTable{44}:=0x00FF9F00
$t_ColorTable{45}:=0x00FFAE10
$t_ColorTable{46}:=0x00FFB107
$t_ColorTable{47}:=0x00FFB804
$t_ColorTable{48}:=0x00FFC000
$t_ColorTable{49}:=0x00FFC704
$t_ColorTable{50}:=0x00FFCE00
$t_ColorTable{51}:=0x00FFD700
$t_ColorTable{52}:=0x00FFDF03
$t_ColorTable{53}:=0x00FFE605
$t_ColorTable{54}:=0x00FFEF0A
$t_ColorTable{55}:=0x00FFF604
$t_ColorTable{56}:=0x00FFFD06
$t_ColorTable{57}:=0x00F9FF00
$t_ColorTable{58}:=0x00F2FF04
$t_ColorTable{59}:=0x00EBFF00
$t_ColorTable{60}:=0x00E2FF00
$t_ColorTable{61}:=0x00D3FF00
$t_ColorTable{62}:=0x00CAFF00
$t_ColorTable{63}:=0x00C3FF00
$t_ColorTable{64}:=0x00BCFF00
$t_ColorTable{65}:=0x00A6FF00
$t_ColorTable{66}:=0x0090FF00
$t_ColorTable{67}:=0x007AFF00
$t_ColorTable{68}:=0x0064FF00
$t_ColorTable{69}:=0x004FFF00
$t_ColorTable{70}:=0x003CFF03
$t_ColorTable{71}:=0x000CFF00
$t_ColorTable{72}:=0x0003FF0C
$t_ColorTable{73}:=0x0004FF23
$t_ColorTable{74}:=0x0000FF35
$t_ColorTable{75}:=0x0000FF4B
$t_ColorTable{76}:=0x0000FF60
$t_ColorTable{77}:=0x0000FF76
$t_ColorTable{78}:=0x0000FF8C
$t_ColorTable{79}:=0x0000FFA7
$t_ColorTable{80}:=0x0000FFA7
$t_ColorTable{81}:=0x0000FFB1
$t_ColorTable{82}:=0x0000FFBB
$t_ColorTable{83}:=0x0000FFC5
$t_ColorTable{84}:=0x0000FFD0
$t_ColorTable{85}:=0x0000FFDA
$t_ColorTable{86}:=0x0000FFE4
$t_ColorTable{87}:=0x0000FFEE
$t_ColorTable{88}:=0x0000FFF8
$t_ColorTable{89}:=0x0000FDFF
$t_ColorTable{90}:=0x0000F3FF
$t_ColorTable{91}:=0x0000E9FF
$t_ColorTable{92}:=0x0000E0FF
$t_ColorTable{93}:=0x0000D5FF
$t_ColorTable{94}:=0x0000CBFF
$t_ColorTable{95}:=0x0000C1FF
$t_ColorTable{96}:=0x0000B4FF
$t_ColorTable{97}:=0x0000A1FF
$t_ColorTable{98}:=0x00008EFF
$t_ColorTable{99}:=0x00007CFF
$t_ColorTable{100}:=0x000069FF
$t_ColorTable{101}:=0x000056FF
$t_ColorTable{102}:=0x000043FF
$t_ColorTable{103}:=0x000128FF
$t_ColorTable{104}:=0x00001EFF
$t_ColorTable{105}:=0x00000BFF
$t_ColorTable{106}:=0x000700FF
$t_ColorTable{107}:=0x001900FF
$t_ColorTable{108}:=0x002C00FF
$t_ColorTable{109}:=0x003F00FF
$t_ColorTable{110}:=0x005200FF
$t_ColorTable{111}:=0x006500FF
$t_ColorTable{112}:=0x007800FF
$t_ColorTable{113}:=0x008B00FF
$t_ColorTable{114}:=0x009E00FF
$t_ColorTable{115}:=0x00B100FF
$t_ColorTable{116}:=0x00C400FF
$t_ColorTable{117}:=0x00D700FF
$t_ColorTable{118}:=0x00EA00FF
$t_ColorTable{119}:=0x00FD00FF
$t_ColorTable{120}:=0x00FF03EF
$t_ColorTable{121}:=0x00FF00DC
$t_ColorTable{122}:=0x00FF00C9
$t_ColorTable{123}:=0x00FF00B6
$t_ColorTable{124}:=0x00FF00A3
$t_ColorTable{125}:=0x00FF0090
$t_ColorTable{126}:=0x00FF007D
$t_ColorTable{127}:=0x00FF006A
$t_ColorTable{128}:=0x00FFE0E0
$t_ColorTable{129}:=0x00FFC0C0
$t_ColorTable{130}:=0x00FFA0A0
$t_ColorTable{131}:=0x00FF7F7F
$t_ColorTable{132}:=0x00FF5F5F
$t_ColorTable{133}:=0x00FF4040
$t_ColorTable{134}:=0x00FF2020
$t_ColorTable{135}:=0x00FF0000
$t_ColorTable{136}:=0x00EC0F00
$t_ColorTable{137}:=0x00D80000
$t_ColorTable{138}:=0x00CF0000
$t_ColorTable{139}:=0x00B00000
$t_ColorTable{140}:=0x009C0000
$t_ColorTable{141}:=0x00880000
$t_ColorTable{142}:=0x00740000
$t_ColorTable{143}:=0x00600000
$t_ColorTable{144}:=0x00FFF0DF
$t_ColorTable{145}:=0x00FFE0C0
$t_ColorTable{146}:=0x00FFCFA0
$t_ColorTable{147}:=0x00FFBE7F
$t_ColorTable{148}:=0x00FFB05F
$t_ColorTable{149}:=0x00FFA140
$t_ColorTable{150}:=0x00FF9120
$t_ColorTable{151}:=0x00FF8100
$t_ColorTable{152}:=0x00EC7700
$t_ColorTable{153}:=0x00D86D00
$t_ColorTable{154}:=0x00C46300
$t_ColorTable{155}:=0x00B05900
$t_ColorTable{156}:=0x009C5200
$t_ColorTable{157}:=0x00884500
$t_ColorTable{158}:=0x00743B00
$t_ColorTable{159}:=0x00603000
$t_ColorTable{160}:=0x00FFFFDF
$t_ColorTable{161}:=0x00FFFFC0
$t_ColorTable{162}:=0x00FFFFA0
$t_ColorTable{163}:=0x00FFFF7F
$t_ColorTable{164}:=0x00FEFF5F
$t_ColorTable{165}:=0x00FEFF40
$t_ColorTable{166}:=0x00FEFF20
$t_ColorTable{167}:=0x00FEFF00
$t_ColorTable{168}:=0x00EAEC00
$t_ColorTable{169}:=0x00D6D700
$t_ColorTable{170}:=0x00C2C300
$t_ColorTable{171}:=0x00AEAF00
$t_ColorTable{172}:=0x009E9F00
$t_ColorTable{173}:=0x00878800
$t_ColorTable{174}:=0x00737400
$t_ColorTable{175}:=0x005F6000
$t_ColorTable{176}:=0x00E2FFDF
$t_ColorTable{177}:=0x00C5FFC0
$t_ColorTable{178}:=0x00A7FFA0
$t_ColorTable{179}:=0x0089FF7F
$t_ColorTable{180}:=0x006CFF5F
$t_ColorTable{181}:=0x004FFF40
$t_ColorTable{182}:=0x0031FF20
$t_ColorTable{183}:=0x0013FF00
$t_ColorTable{184}:=0x0012EC00
$t_ColorTable{185}:=0x0010D800
$t_ColorTable{186}:=0x000FC400
$t_ColorTable{187}:=0x000DB000
$t_ColorTable{188}:=0x000C9C00
$t_ColorTable{189}:=0x000A8800
$t_ColorTable{190}:=0x00097400
$t_ColorTable{191}:=0x00076000
$t_ColorTable{192}:=0x00DFFFFF
$t_ColorTable{193}:=0x00C0FFFF
$t_ColorTable{194}:=0x00A0FFFF
$t_ColorTable{195}:=0x007FFEFF
$t_ColorTable{196}:=0x005FFEFF
$t_ColorTable{197}:=0x0040FEFF
$t_ColorTable{198}:=0x0020FDFF
$t_ColorTable{199}:=0x0000FDFF
$t_ColorTable{200}:=0x0000E9EC
$t_ColorTable{201}:=0x0000D6D8
$t_ColorTable{202}:=0x0000C2C4
$t_ColorTable{203}:=0x0000AEB0
$t_ColorTable{204}:=0x00009B9C
$t_ColorTable{205}:=0x00008788
$t_ColorTable{206}:=0x00007374
$t_ColorTable{207}:=0x00005F60
$t_ColorTable{208}:=0x00DFE4FF
$t_ColorTable{209}:=0x00C0CAFF
$t_ColorTable{210}:=0x00A0AFFF
$t_ColorTable{211}:=0x007F93FF
$t_ColorTable{212}:=0x005F78FF
$t_ColorTable{213}:=0x00405EFF
$t_ColorTable{214}:=0x002042FF
$t_ColorTable{215}:=0x000027FF
$t_ColorTable{216}:=0x000024EC
$t_ColorTable{217}:=0x000021D8
$t_ColorTable{218}:=0x000020CF
$t_ColorTable{219}:=0x00001BB0
$t_ColorTable{220}:=0x0000189C
$t_ColorTable{221}:=0x00001588
$t_ColorTable{222}:=0x00001274
$t_ColorTable{223}:=0x00000E60
$t_ColorTable{224}:=0x00FFDFFF
$t_ColorTable{225}:=0x00FFC0FF
$t_ColorTable{226}:=0x00FFA0FF
$t_ColorTable{227}:=0x00FF7FFF
$t_ColorTable{228}:=0x00FF5FFF
$t_ColorTable{229}:=0x00FF40FF
$t_ColorTable{230}:=0x00FF20FF
$t_ColorTable{231}:=0x00FF00FF
$t_ColorTable{232}:=0x00EB00EC
$t_ColorTable{233}:=0x00D700D8
$t_ColorTable{234}:=0x00CF00CF
$t_ColorTable{235}:=0x00B000B0
$t_ColorTable{236}:=0x009C009C
$t_ColorTable{237}:=0x00880088
$t_ColorTable{238}:=0x00740074
$t_ColorTable{239}:=0x00600060
$t_ColorTable{240}:=0x00FFFFFF
$t_ColorTable{241}:=0x00EEEEEE
$t_ColorTable{242}:=0x00DDDDDD
$t_ColorTable{243}:=0x00CCCCCC
$t_ColorTable{244}:=0x00C0C0C0
$t_ColorTable{245}:=0x00AAAAAA
$t_ColorTable{246}:=0x00999999
$t_ColorTable{247}:=0x00888888
$t_ColorTable{248}:=0x00777777
$t_ColorTable{249}:=0x00666666
$t_ColorTable{250}:=0x00555555
$t_ColorTable{251}:=0x00404040
$t_ColorTable{252}:=0x00333333
$t_ColorTable{253}:=0x00222222
$t_ColorTable{254}:=0x00111111
$t_ColorTable{255}:=0x00000000

$0:=$t_ColorTable{$1}


The utility method is simple to use, just pass in the constant and it will return the converted value:
OBJECT SET COLOR(*;"myRectangle";Black)


Can be updated to the following:
OBJECT SET RGB COLORS(*;"myRectangle";Util_4DColorToHex(Black))

Commented by David Nasralla on December 16, 2020 at 9:48 AM
I'm not sure when you would ever use this command, since the OBJECT SET RGB COLORS allows you to pass the text name of the color you want. EG: OBJECT SET RGB COLORS(*;"myRectangle";"Black")