Setting a wall's coarse scale fill pattern color

See this link for the logic behind the number:
http://thebuildingcoder.typepad.com/blog/2013/04/migrating-a-built-in-category-and-other-things.html#3

#Storage of RGB Colour Values for Materials

Question: I looked at a material element ‘Color’ parameter value today. This parameter values comes back as an integer.

It appears to me to have the red and blue values reversed.

When looking at the ‘Site – Earth’ material in the rac_advanced_sample_project included with Revit, the Color property on the material class returns material.Color.Red=97, material.Color.Green=75 and material.Color.Blue=62, which is also what the Revit GUI shows in ‘Manage Materials’. I checked on an online colour generator web site and it looks the same as in the Revit GUI, a dirty brown colour.

However, the integer number that comes back from the ‘Color’ parameter on the material element is 4082529, which when converted to RGB values using online converters, comes back as Red=62, Green=75 and Blue=97, which is a bluish colour. The Red and Blue values appear to be reversed.

I would have expected the integer 6376254 to be returned for this colour instead.

Can you explain this, please?

Answer: Yes, easily.

This is actually working as expected.

Revit uses the Windows convention of storing colours as an RGB COLORREF value in a DWORD (32 bit integer) that specifies “The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green; and the third byte contains a value for blue”.

In other words it is (A)BGR and not (A)RGB.

This corresponds to the value of the integer returned from a Color parameter.

1 Like