See #1227. Fix inconsistent layer UI based on direction sense and minor UI cleanup.

The UI here looks suspicious in that logic is occuring in the draw call
instead of the cached data object.
This commit is contained in:
Dion Moult
2025-03-09 19:28:47 +11:00
parent 4109b19c3a
commit 8ffb5c56e4
2 changed files with 32 additions and 32 deletions
@@ -244,6 +244,8 @@ class ObjectMaterialData:
items = []
if cls.material.is_a("IfcMaterialLayerSetUsage"):
items = cls.material.ForLayerSet.MaterialLayers
if cls.material.DirectionSense == "POSITIVE":
items = reversed(items)
elif cls.material.is_a("IfcMaterialProfileSetUsage"):
items = cls.material.ForProfileSet.MaterialProfiles
elif cls.material.is_a("IfcMaterialLayerSet"):
@@ -308,7 +310,13 @@ class ObjectMaterialData:
layers = cls.material.ForLayerSet.MaterialLayers
elif cls.material.is_a("IfcMaterialLayerSet"):
layers = cls.material.MaterialLayers
return sum([l.LayerThickness for l in layers or []])
thickness = sum([l.LayerThickness for l in layers or []])
props = tool.Drawing.get_document_props()
unit_system = bpy.context.scene.unit_settings.system
precision = None
if unit_system == "IMPERIAL":
precision = props.imperial_precision
return format_distance(thickness, precision=precision, suppress_zero_inches=True, in_unit_length=True)
@classmethod
def set_item_name(cls) -> Union[str, None]:
+23 -31
View File
@@ -24,7 +24,6 @@ from bpy.types import Panel, UIList
from bonsai.bim.helper import draw_attributes
from bonsai.bim.helper import prop_with_search
from bonsai.bim.module.material.data import MaterialsData, ObjectMaterialData
from bonsai.bim.module.drawing.helper import format_distance
from typing import TYPE_CHECKING
if TYPE_CHECKING:
@@ -336,38 +335,28 @@ class BIM_PT_object_material(Panel):
if ObjectMaterialData.data["material_class"] != "IfcMaterialList":
row = self.layout.row(align=True)
set_name = ObjectMaterialData.data["set"]["name"]
row.label(text=f" Name: {set_name}")
row.label(text="Name")
row.label(text=set_name)
if ObjectMaterialData.data["set"]["description"]:
set_description = ObjectMaterialData.data["set"]["description"]
if value := ObjectMaterialData.data["set"]["description"]:
row = self.layout.row(align=True)
row.label(text=f" Description: {set_description}")
row.label(text="Description")
row.label(text=value)
if ObjectMaterialData.data["material_class"] == "IfcMaterialProfileSetUsage":
if ObjectMaterialData.data["set_usage"].get("cardinal_point"):
cardinal_point = ObjectMaterialData.data["set_usage"]["cardinal_point"]
if value := ObjectMaterialData.data["set_usage"].get("cardinal_point"):
row = self.layout.row(align=True)
row.label(text=f" Cardinal Point: {cardinal_point}")
row.label(text="Cardinal Point")
row.label(text=value)
if ObjectMaterialData.data["total_thickness"]:
total_thickness = ObjectMaterialData.data["total_thickness"]
unit_system = bpy.context.scene.unit_settings.system
props = tool.Drawing.get_document_props()
if unit_system == "IMPERIAL":
precision = props.imperial_precision
else:
precision = None
formatted_thickness = format_distance(
total_thickness, precision=precision, suppress_zero_inches=True, in_unit_length=True
)
row = self.layout.row(align=True)
row.label(text=f" Total Thickness: {formatted_thickness}")
row.label(text="Total Thickness*")
row.label(text=ObjectMaterialData.data["total_thickness"])
layout = self.layout
box = layout.box()
box = self.layout.box()
active_object = bpy.context.active_object
self.layerset_bounds(box, active_object, location="Top_Exterior")
self.layerset_bounds(box, active_object, location="Top_Interior")
for set_item in ObjectMaterialData.data["set_items"]:
material_name = set_item["material"]
@@ -383,22 +372,25 @@ class BIM_PT_object_material(Panel):
op = row.operator("bim.select_by_material", text=material_name, emboss=False)
op.material = material_id
self.layerset_bounds(box, active_object, location="Bottom_Interior")
self.layerset_bounds(box, active_object, location="Bottom_Exterior")
def layerset_bounds(self, box, obj, location="Top_Exterior"):
def layerset_bounds(self, layout, obj, location="Top_Interior"):
set_usage = ObjectMaterialData.data.get("set_usage", {})
layer_set_direction = set_usage.get("layer_set_direction")
if layer_set_direction:
if location == "Top_Exterior":
row = layout.row()
row.alignment = "CENTER"
row.enabled = False
if location == "Top_Interior":
if layer_set_direction == "AXIS3":
box.label(text="----- Top -----")
row.label(text="Top")
else:
box.label(text="----- Exterior -----")
if location == "Bottom_Interior":
row.label(text="Interior")
elif location == "Bottom_Exterior":
if layer_set_direction == "AXIS3":
box.label(text="----- Bottom -----")
row.label(text="Bottom")
else:
box.label(text="----- Interior -----")
row.label(text="Exterior")
class BIM_UL_materials(UIList):