Correspondance ACI (AutoCAD Color Index) RGB AutoCAD

IMPORTANT : note de l'administrateur

Vous pourrez trouver différentes versions de cette table de correspondance sur le Web. Attention, il ne semble pas facile d’obtenir une version exacte. @serge.camire a retravaillé le sujet récemment et a trouvé des incohérences entre le résultat des fonctions DotNet qui liste les valeurs RGB et celles affichées par la boite de dialogue AutoCAD®… Donc avis aux spécialistes, si vous avez des infos, à ce sujet, n’hésitez pas à répondre à cette discussion, merci!

aci-autocad-color-index

ACI R G B Code
0 0 0 0 0
1 255 0 0 16711680
2 255 255 0 16776960
3 0 255 0 65280
4 0 255 255 65535
5 0 0 255 255
6 255 0 255 16711935
7 255 255 255 16777215
8 128 128 128 8421504
9 192 192 192 12632256
10 255 0 0 16711680
11 255 127 127 16744319
12 204 0 0 13369344
13 204 102 102 13395558
14 153 0 0 10027008
15 153 76 76 10046540
16 127 0 0 8323072
17 127 63 63 8339263
18 76 0 0 4980736
19 76 38 38 4990502
20 255 63 0 16727808
21 255 159 127 16752511
22 204 51 0 13382400
23 204 127 102 13401958
24 153 38 0 10036736
25 153 95 76 10051404
26 127 31 0 8331008
27 127 79 63 8343359
28 76 19 0 4985600
29 76 47 38 4992806
30 255 127 0 16744192
31 255 191 127 16760703
32 204 102 0 13395456
33 204 153 102 13408614
34 153 76 0 10046464
35 153 114 76 10056268
36 127 63 0 8339200
37 127 95 63 8347455
38 76 38 0 4990464
39 76 57 38 4995366
40 255 191 0 16760576
41 255 223 127 16768895
42 204 153 0 13408512
43 204 178 102 13415014
44 153 114 0 10056192
45 153 133 76 10061132
46 127 95 0 8347392
47 127 111 63 8351551
48 76 57 0 4995328
49 76 66 38 4997670
50 255 255 0 16776960
51 255 255 127 16777087
52 204 204 0 13421568
53 204 204 102 13421670
54 153 153 0 10066176
55 153 153 76 10066252
56 127 127 0 8355584
57 127 127 63 8355647
58 76 76 0 5000192
59 76 76 38 5000230
60 191 255 0 12582656
61 223 255 127 14679935
62 153 204 0 10079232
63 178 204 102 11717734
64 114 153 0 7510272
65 133 153 76 8755532
66 95 127 0 6258432
67 111 127 63 7307071
68 57 76 0 3755008
69 66 76 38 4344870
70 127 255 0 8388352
71 191 255 127 12582783
72 102 204 0 6736896
73 153 204 102 10079334
74 76 153 0 5019904
75 114 153 76 7510348
76 63 127 0 4161280
77 95 127 63 6258495
78 38 76 0 2509824
79 57 76 38 3755046
80 63 255 0 4194048
81 159 255 127 10485631
82 51 204 0 3394560
83 127 204 102 8375398
84 38 153 0 2529536
85 95 153 76 6265164
86 31 127 0 2064128
87 79 127 63 5209919
88 19 76 0 1264640
89 47 76 38 3099686
90 0 255 0 65280
91 127 255 127 8388479
92 0 204 0 52224
93 102 204 102 6736998
94 0 153 0 39168
95 76 153 76 5019980
96 0 127 0 32512
97 63 127 63 4161343
98 0 76 0 19456
99 38 76 38 2509862
100 0 255 63 65343
101 127 255 159 8388511
102 0 204 51 52275
103 102 204 127 6737023
104 0 153 38 39206
105 76 153 95 5019999
106 0 127 31 32543
107 63 127 79 4161359
108 0 76 19 19475
109 38 76 47 2509871
110 0 255 127 65407
111 127 255 191 8388543
112 0 204 102 52326
113 102 204 153 6737049
114 0 153 76 39244
115 76 153 114 5020018
116 0 127 63 32575
117 63 127 95 4161375
118 0 76 38 19494
119 38 76 57 2509881
120 0 255 191 65471
121 127 255 223 8388575
122 0 204 153 52377
123 102 204 178 6737074
124 0 153 114 39282
125 76 153 133 5020037
126 0 127 95 32607
127 63 127 111 4161391
128 0 76 57 19513
129 38 76 66 2509890
130 0 255 255 65535
131 127 255 255 8388607
132 0 204 204 52428
133 102 204 204 6737100
134 0 153 153 39321
135 76 153 153 5020057
136 0 127 127 32639
137 63 127 127 4161407
138 0 76 76 19532
139 38 76 76 2509900
140 0 191 255 49151
141 127 223 255 8380415
142 0 153 204 39372
143 102 178 204 6730444
144 0 114 153 29337
145 76 133 153 5014937
146 0 95 127 24447
147 63 111 127 4157311
148 0 57 76 14668
149 38 66 76 2507340
150 0 127 255 32767
151 127 191 255 8372223
152 0 102 204 26316
153 102 153 204 6724044
154 0 76 153 19609
155 76 114 153 5010073
156 0 63 127 16255
157 63 95 127 4153215
158 0 38 76 9804
159 38 57 76 2505036
160 0 63 255 16383
161 127 159 255 8364031
162 0 51 204 13260
163 102 127 204 6717388
164 0 38 153 9881
165 76 95 153 5005209
166 0 31 127 8063
167 63 79 127 4149119
168 0 19 76 4940
169 38 47 76 2502476
170 0 0 255 255
171 127 127 255 8355839
172 0 0 204 204
173 102 102 204 6710988
174 0 0 153 153
175 76 76 153 5000345
176 0 0 127 127
177 63 63 127 4145023
178 0 0 76 76
179 38 38 76 2500172
180 63 0 255 4129023
181 159 127 255 10452991
182 51 0 204 3342540
183 127 102 204 8349388
184 38 0 153 2490521
185 95 76 153 6245529
186 31 0 127 2031743
187 79 63 127 5193599
188 19 0 76 1245260
189 47 38 76 3089996
190 127 0 255 8323327
191 191 127 255 12550143
192 102 0 204 6684876
193 153 102 204 10053324
194 76 0 153 4980889
195 114 76 153 7490713
196 63 0 127 4128895
197 95 63 127 6242175
198 38 0 76 2490444
199 57 38 76 3745356
200 191 0 255 12517631
201 223 127 255 14647295
202 153 0 204 10027212
203 178 102 204 11691724
204 114 0 153 7471257
205 133 76 153 8735897
206 95 0 127 6226047
207 111 63 127 7290751
208 57 0 76 3735628
209 66 38 76 4335180
210 255 0 255 16711935
211 255 127 255 16744447
212 204 0 204 13369548
213 204 102 204 13395660
214 153 0 153 10027161
215 153 76 153 10046617
216 127 0 127 8323199
217 127 63 127 8339327
218 76 0 76 4980812
219 76 38 76 4990540
220 255 0 191 16711871
221 255 127 223 16744415
222 204 0 153 13369497
223 204 102 178 13395634
224 153 0 114 10027122
225 153 76 133 10046597
226 127 0 95 8323167
227 127 63 111 8339311
228 76 0 57 4980793
229 76 38 66 4990530
230 255 0 127 16711807
231 255 127 191 16744383
232 204 0 102 13369446
233 204 102 153 13395609
234 153 0 76 10027084
235 153 76 114 10046578
236 127 0 63 8323135
237 127 63 95 8339295
238 76 0 38 4980774
239 76 38 57 4990521
240 255 0 63 16711743
241 255 127 159 16744351
242 204 0 51 13369395
243 204 102 127 13395583
244 153 0 38 10027046
245 153 76 95 10046559
246 127 0 31 8323103
247 127 63 79 8339279
248 76 0 19 4980755
249 76 38 47 4990511
250 51 51 51 3355443
251 91 91 91 5987163
252 132 132 132 8684676
253 173 173 173 11382189
254 214 214 214 14079702
255 255 255 255 16777215

C’est toujours utile. Je m’étais fait une fonction pour DotNet (ici, en VB). Il arrive d’avoir besoin de ce type de conversion. À noter que les codes 0, 256 et 257 réfèrent à des métacouleurs, respectivement « ByBlock/DuBloc », « ByLayer/DuCalque » et « interne ». Par interne, c’est une couleur par défaut (Abstract) qu’AutoCAD® assigne à tout objet en création avant qu’elle n’hérite de la couleur finale. On ne peut y accéder qu’avec ObjectARX et c’est peu d’intérêt.


Imports Autodesk.AutoCAD.Colors.EntityColor

Imports Autodesk.AutoCAD.Runtime

 

' Traduction VB à C# : https://www.carlosag.net/tools/codetranslator/

Public Class Class1

 

   ''' <summary>

   ''' Conversion de couleur ACI à RGB. La sortie va dans un fichier.
   ''' Après chargement, exécuter ACI2RGB sur la ligne de commande
   ''' Le fichier créé se trouve à la racine du lecteur C:
   ''' Conversion de couleur ACI à RGB. La sortie va dans un fichier.
   ''' Après chargement, exécuter ACI2RGB sur la ligne de commande.
   ''' Le fichier créé se trouve à la racine du lecteur C:.
   ''' Par Serge Camiré
   ''' </summary>

   <CommandMethod("ACI2RGB")>

   Public Sub ACI2RGB()

      Dim ACI_ColorIndex As Integer

      Dim byt As System.Byte

      Dim RGB As Integer

      Dim B, G, R As Long

      Dim BI, GI, RI As Integer

      Dim FullFilename As String = "C\ACI2RGB.txt"

      Dim sb As Text.StringBuilder = New Text.StringBuilder

      Dim ExportLineTemplate As String = "{0}" & vbTab & "{1}" & vbTab & "{2}" & vbTab & "{3}" & vbTab & "{4}" & vbTab & "{5}"

      Dim ExportLine As String = String.Format(ExportLineTemplate, "ACI", "R", "G", "B", "Hex", vbTab & "Integer")

      sb.AppendLine(ExportLine)

 

      For i As Integer = 1 To 255

         Try

            byt = System.Convert.ToByte(i)

            ACI_ColorIndex = LookUpRgb(byt)

            RGB = Autodesk.AutoCAD.Colors.EntityColor.LookUpRgb(byt)

 

            R = (RGB And &HFF0000L) >> 16

            G = (RGB And &HFF00L) >> 8

            B = (RGB And &HFFL)

 

            RI = System.Convert.ToInt32(R)

            GI = System.Convert.ToInt32(G)

            BI = System.Convert.ToInt32(B)

 

            ExportLine = String.Format(ExportLineTemplate, i, RI, GI, BI,

                                       "#" & RI.ToString("X2") & GI.ToString("X2") & BI.ToString("X2"),

                                       RI * 2 ^ 16 + GI * 2 ^ 8 + BI)

            sb.AppendLine(ExportLine)

 

         Catch ex As IO.IOException

            Debug.Print("")

         End Try

      Next

 

      Try

         Using sw As IO.StreamWriter = New IO.StreamWriter(FullFilename, False, System.Text.Encoding.Default)

            sw.Write(sb.ToString)

            sw.Close()

         End Using

      Catch ex As IO.IOException

         Debug.Print("")

      End Try

 

   End Sub

 

End Class
1 « J'aime »

Bonjour @serge.camire, il me semble que le tableau que j’avais publié ici était une de tes créations si je ne me trompe pas bien qu’il en existe différentes versions sur internet mais tu sembles bien connaître le sujet et au cas où tu pourrais nous en dire plus dans cette discussion, n’hésites pas à y intervenir :