Representation items panel now shows styles and layers

This commit is contained in:
Dion Moult
2023-10-12 22:56:21 +11:00
parent c930050da6
commit dd70b09fb1
4 changed files with 33 additions and 4 deletions
@@ -99,7 +99,11 @@ class RepresentationItemsData:
@classmethod
def load(cls):
cls.data = {"total_items": cls.total_items()}
cls.data = {
"total_items": cls.total_items(),
"active_surface_style": cls.active_surface_style(),
"active_layer": cls.active_layer(),
}
cls.is_loaded = True
@classmethod
@@ -120,6 +124,18 @@ class RepresentationItemsData:
result += 1
return result
@classmethod
def active_surface_style(cls):
props = bpy.context.active_object.BIMGeometryProperties
if props.active_item_index < len(props.items):
return props.items[props.active_item_index].surface_style
@classmethod
def active_layer(cls):
props = bpy.context.active_object.BIMGeometryProperties
if props.active_item_index < len(props.items):
return props.items[props.active_item_index].layer
class ConnectionsData:
data = {}
@@ -41,6 +41,7 @@ def get_contexts(self, context):
class RepresentationItem(PropertyGroup):
name: StringProperty(name="Name")
surface_style: StringProperty(name="Surface Style")
layer: StringProperty(name="Layer")
ifc_definition_id: IntProperty(name="IFC Definition ID")
@@ -164,6 +164,18 @@ class BIM_PT_representation_items(Panel):
self.layout.template_list("BIM_UL_representation_items", "", props, "items", props, "active_item_index")
row = self.layout.row()
if RepresentationItemsData.data["active_surface_style"]:
row.label(text=RepresentationItemsData.data["active_surface_style"], icon="MATERIAL")
else:
row.label(text="No Surface Style", icon="MESH_UVSPHERE")
row = self.layout.row()
if RepresentationItemsData.data["active_layer"]:
row.label(text=RepresentationItemsData.data["active_layer"], icon="STICKY_UVS_LOC")
else:
row.label(text="No Presentation Layer", icon="STICKY_UVS_LOC")
class BIM_PT_connections(Panel):
bl_label = "Connections"
@@ -423,5 +435,5 @@ class BIM_UL_representation_items(UIList):
icon = "MATERIAL" if item.surface_style else "MESH_UVSPHERE"
row = layout.row(align=True)
row.label(text=item.name, icon=icon)
if item.surface_style:
row.label(text=item.surface_style)
if item.layer:
row.label(text="", icon="STICKY_UVS_LOC")
@@ -577,7 +577,7 @@ def get_elements_by_layer(ifc_file, layer):
:rtype: list[ifcopenshell.entity_instance.entity_instance]
"""
results = set()
for item in layer.AssignedItems:
for item in layer.AssignedItems or []:
if item.is_a("IfcShapeRepresentation"):
results.update(get_elements_by_representation(ifc_file, item))
elif item.is_a("IfcRepresentationItem"):