mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 15:26:33 +00:00
Improved UI for BIM_PT_object_material
also can run `bim.select_by_material` by clicking on material name
This commit is contained in:
@@ -207,9 +207,14 @@ class BIM_PT_object_material(Panel):
|
|||||||
prop_with_search(self.layout, self.props, "material", text="")
|
prop_with_search(self.layout, self.props, "material", text="")
|
||||||
|
|
||||||
def draw_read_only_single_ui(self):
|
def draw_read_only_single_ui(self):
|
||||||
row = self.layout.row(align=True)
|
material_id = ObjectMaterialData.data["material_id"]
|
||||||
|
layout = self.layout
|
||||||
|
box = layout.box()
|
||||||
|
row = box.row()
|
||||||
row.label(text="Name")
|
row.label(text="Name")
|
||||||
row.label(text=ObjectMaterialData.data["material_name"])
|
op = row.operator("bim.select_by_material", text=ObjectMaterialData.data["material_name"], icon="NONE", emboss=False)
|
||||||
|
op.material = material_id
|
||||||
|
|
||||||
|
|
||||||
def draw_set_ui(self):
|
def draw_set_ui(self):
|
||||||
if self.props.is_editing:
|
if self.props.is_editing:
|
||||||
@@ -225,6 +230,9 @@ class BIM_PT_object_material(Panel):
|
|||||||
row.label(text="No Profiles Available")
|
row.label(text="No Profiles Available")
|
||||||
row.operator("bim.add_profile_def", icon="ADD", text="")
|
row.operator("bim.add_profile_def", icon="ADD", text="")
|
||||||
else:
|
else:
|
||||||
|
layout = self.layout
|
||||||
|
layout.separator()
|
||||||
|
layout.separator()
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
if ObjectMaterialData.data["set_item_name"] == "profile":
|
if ObjectMaterialData.data["set_item_name"] == "profile":
|
||||||
prop_with_search(row, self.mprops, "profiles", icon="ITALIC", text="")
|
prop_with_search(row, self.mprops, "profiles", icon="ITALIC", text="")
|
||||||
@@ -233,12 +241,12 @@ class BIM_PT_object_material(Panel):
|
|||||||
setattr(op, f"{ObjectMaterialData.data['set_item_name']}_set", ObjectMaterialData.data["set"]["id"])
|
setattr(op, f"{ObjectMaterialData.data['set_item_name']}_set", ObjectMaterialData.data["set"]["id"])
|
||||||
|
|
||||||
total_items = len(ObjectMaterialData.data["set_items"])
|
total_items = len(ObjectMaterialData.data["set_items"])
|
||||||
row = self.layout.row(align=True)
|
|
||||||
layer_set_direction = self.props.material_set_usage_attributes["LayerSetDirection"].enum_value
|
layout = self.layout
|
||||||
if layer_set_direction == "AXIS3":
|
box = layout.box()
|
||||||
row.label(text="----- Top -----")
|
active_object = bpy.context.active_object
|
||||||
else:
|
self.layerset_bounds (box, active_object, location="Top_Exterior")
|
||||||
row.label(text="----- Exterior -----")
|
|
||||||
for index, set_item in enumerate(ObjectMaterialData.data["set_items"]):
|
for index, set_item in enumerate(ObjectMaterialData.data["set_items"]):
|
||||||
if (
|
if (
|
||||||
len(self.props.material_set_item_profile_attributes)
|
len(self.props.material_set_item_profile_attributes)
|
||||||
@@ -248,12 +256,9 @@ class BIM_PT_object_material(Panel):
|
|||||||
elif self.props.active_material_set_item_id == set_item["id"]:
|
elif self.props.active_material_set_item_id == set_item["id"]:
|
||||||
self.draw_editable_set_item_ui(set_item)
|
self.draw_editable_set_item_ui(set_item)
|
||||||
else:
|
else:
|
||||||
self.draw_read_only_set_item_ui(set_item, index, is_first=index == 0, is_last=index == total_items - 1)
|
self.draw_read_only_set_item_ui(box, set_item, index, is_first=index == 0, is_last=index == total_items - 1)
|
||||||
row = self.layout.row(align=True)
|
|
||||||
if layer_set_direction == "AXIS3":
|
self.layerset_bounds (box, active_object, location="Bottom_Interior")
|
||||||
row.label(text="----- Bottom -----")
|
|
||||||
else:
|
|
||||||
row.label(text="----- Interior -----")
|
|
||||||
|
|
||||||
def draw_editable_set_item_profile_ui(self, set_item):
|
def draw_editable_set_item_profile_ui(self, set_item):
|
||||||
box = self.layout.box()
|
box = self.layout.box()
|
||||||
@@ -279,13 +284,13 @@ class BIM_PT_object_material(Panel):
|
|||||||
row = box.row()
|
row = box.row()
|
||||||
prop_with_search(row, self.mprops, "profiles", icon="ITALIC", text="Profile")
|
prop_with_search(row, self.mprops, "profiles", icon="ITALIC", text="Profile")
|
||||||
|
|
||||||
def draw_read_only_set_item_ui(self, set_item, index, is_first=False, is_last=False):
|
def draw_read_only_set_item_ui(self, box, set_item, index, is_first=False, is_last=False):
|
||||||
if ObjectMaterialData.data["material_class"] == "IfcMaterialList":
|
if ObjectMaterialData.data["material_class"] == "IfcMaterialList":
|
||||||
row = self.layout.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text="IfcMaterial", icon="LAYER_ACTIVE")
|
row.label(text="IfcMaterial", icon="LAYER_ACTIVE")
|
||||||
row.label(text=set_item["name"], icon="MATERIAL")
|
row.label(text=set_item["name"], icon="MATERIAL")
|
||||||
else:
|
else:
|
||||||
row = self.layout.row(align=True)
|
row = box.row(align=True)
|
||||||
row.label(text=set_item["name"], icon=set_item["icon"])
|
row.label(text=set_item["name"], icon=set_item["icon"])
|
||||||
row.label(text=set_item["material"], icon="MATERIAL")
|
row.label(text=set_item["material"], icon="MATERIAL")
|
||||||
|
|
||||||
@@ -322,29 +327,19 @@ class BIM_PT_object_material(Panel):
|
|||||||
def draw_read_only_set_ui(self):
|
def draw_read_only_set_ui(self):
|
||||||
if ObjectMaterialData.data["material_class"] != "IfcMaterialList":
|
if ObjectMaterialData.data["material_class"] != "IfcMaterialList":
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Name")
|
set_name = ObjectMaterialData.data["set"]["name"]
|
||||||
row.label(text=ObjectMaterialData.data["set"]["name"])
|
row.label(text=f" Name: {set_name}")
|
||||||
|
|
||||||
if ObjectMaterialData.data["set"]["description"]:
|
if ObjectMaterialData.data["set"]["description"]:
|
||||||
|
set_description = ObjectMaterialData.data["set"]["description"]
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="Description")
|
row.label(text=f" Description: {set_description}")
|
||||||
row.label(text=ObjectMaterialData.data["set"]["description"])
|
|
||||||
|
|
||||||
if ObjectMaterialData.data["material_class"] == "IfcMaterialProfileSetUsage":
|
if ObjectMaterialData.data["material_class"] == "IfcMaterialProfileSetUsage":
|
||||||
if ObjectMaterialData.data["set_usage"].get("cardinal_point"):
|
if ObjectMaterialData.data["set_usage"].get("cardinal_point"):
|
||||||
|
cardinal_point = ObjectMaterialData.data["set_usage"]["cardinal_point"]
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text="CardinalPoint")
|
row.label(text=f" Cardinal Point: {cardinal_point}")
|
||||||
row.label(text=ObjectMaterialData.data["set_usage"]["cardinal_point"])
|
|
||||||
|
|
||||||
for set_item in ObjectMaterialData.data["set_items"]:
|
|
||||||
if ObjectMaterialData.data["material_class"] == "IfcMaterialList":
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text="IfcMaterial", icon="LAYER_ACTIVE")
|
|
||||||
row.label(text=set_item["name"], icon="MATERIAL")
|
|
||||||
else:
|
|
||||||
row = self.layout.row(align=True)
|
|
||||||
row.label(text=set_item["name"], icon=set_item["icon"])
|
|
||||||
row.label(text=set_item["material"], icon="MATERIAL")
|
|
||||||
|
|
||||||
if ObjectMaterialData.data["total_thickness"]:
|
if ObjectMaterialData.data["total_thickness"]:
|
||||||
total_thickness = ObjectMaterialData.data["total_thickness"]
|
total_thickness = ObjectMaterialData.data["total_thickness"]
|
||||||
@@ -358,9 +353,60 @@ class BIM_PT_object_material(Panel):
|
|||||||
total_thickness, precision=precision, suppress_zero_inches=True, in_unit_length=True
|
total_thickness, precision=precision, suppress_zero_inches=True, in_unit_length=True
|
||||||
)
|
)
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
row.label(text=f"Total Thickness: {formatted_thickness}")
|
row.label(text=f" Total Thickness: {formatted_thickness}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
layout = self.layout
|
||||||
|
box = layout.box()
|
||||||
|
active_object = bpy.context.active_object
|
||||||
|
self.layerset_bounds (box, active_object, location="Top_Exterior")
|
||||||
|
|
||||||
|
|
||||||
|
for set_item in ObjectMaterialData.data["set_items"]:
|
||||||
|
material_name = set_item["material"]
|
||||||
|
material_id = self.get_material_id_from_name(material_name)
|
||||||
|
if ObjectMaterialData.data["material_class"] == "IfcMaterialList":
|
||||||
|
row = box.row()
|
||||||
|
row.label(text="IfcMaterial", icon="LAYER_ACTIVE")
|
||||||
|
op = row.operator("bim.select_by_material", text=material_name, emboss=False)
|
||||||
|
op.material = material_id
|
||||||
|
else:
|
||||||
|
row = box.row()
|
||||||
|
row.label(text=set_item["name"], icon=set_item["icon"])
|
||||||
|
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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_material_id_from_name(self, material_name):
|
||||||
|
for index, set_item in enumerate(ObjectMaterialData.data["materials"]):
|
||||||
|
if material_name == ObjectMaterialData.data["materials"][index][1]:
|
||||||
|
material_id = int(ObjectMaterialData.data["materials"][index][0])
|
||||||
|
return material_id
|
||||||
|
|
||||||
|
|
||||||
|
def layerset_bounds (self, box, obj, location="Top_Exterior"):
|
||||||
|
element = tool.Ifc.get_entity(obj)
|
||||||
|
has_layersetdirection = hasattr(element.HasAssociations[0].RelatingMaterial, "LayerSetDirection")
|
||||||
|
if has_layersetdirection:
|
||||||
|
layer_set_direction = element.HasAssociations[0].RelatingMaterial.LayerSetDirection
|
||||||
|
if location == "Top_Exterior":
|
||||||
|
if layer_set_direction == "AXIS3":
|
||||||
|
box.label(text="----- Top -----")
|
||||||
|
else:
|
||||||
|
box.label(text="----- Exterior -----")
|
||||||
|
if location == "Bottom_Interior":
|
||||||
|
if layer_set_direction == "AXIS2":
|
||||||
|
box.label(text="----- Bottom -----")
|
||||||
|
else:
|
||||||
|
box.label(text="----- Interior -----")
|
||||||
|
|
||||||
|
|
||||||
class BIM_UL_materials(UIList):
|
class BIM_UL_materials(UIList):
|
||||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||||
mprops = context.scene.BIMMaterialProperties
|
mprops = context.scene.BIMMaterialProperties
|
||||||
|
|||||||
Reference in New Issue
Block a user