Skip to content

Commit

Permalink
BBIM, bcf gui, fix colors for hex with alpha channel
Browse files Browse the repository at this point in the history
  • Loading branch information
berndhahnebach committed Apr 12, 2024
1 parent 07f5e7d commit cd2cd73
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/blenderbim/blenderbim/bim/module/bcf/operator.py
Expand Up @@ -1033,7 +1033,7 @@ def set_colours(self, viewpoint):
for acomponent in acoloring.component:
global_id_colours.setdefault(acomponent.ifc_guid, acoloring.color)
for global_id, color in global_id_colours.items():
# print("{}: color: {}".format(global_id, self.hex_to_rgb(color)))
# print("{}: color: {}: {}".format(global_id, color, self.hex_to_rgb(color)))
obj = IfcStore.get_element(global_id)
if obj:
# print(" obj found ")
Expand Down Expand Up @@ -1120,8 +1120,14 @@ def create_bitmaps(self, bcfxml, viewpoint, topic):
def hex_to_rgb(self, value):
value = value.lstrip("#")
lv = len(value)
t = tuple(int(value[i : i + lv // 3], 16) for i in range(0, lv, lv // 3))
return [t[0] / 255.0, t[1] / 255.0, t[2] / 255.0, 1]
# https://github.com/buildingSMART/BCF-XML/tree/release_3_0/Documentation#coloring
if lv == 8:
t = tuple(int(value[i : i + lv // 4], 16) for i in range(0, lv, lv // 4))
col = [t[1] / 255.0, t[2] / 255.0, t[3] / 255.0, t[0] / 255.0]
else:
t = tuple(int(value[i : i + lv // 3], 16) for i in range(0, lv, lv // 3))
col = [t[0] / 255.0, t[1] / 255.0, t[2] / 255.0, 1]
return col


class OpenBcfReferenceLink(bpy.types.Operator):
Expand Down

0 comments on commit cd2cd73

Please sign in to comment.