mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 14:07:43 +00:00
Fix #2981. Standard case windows can now have different materials and implement shape aspects.
This commit is contained in:
@@ -521,6 +521,11 @@ class BIMWindowProperties(PropertyGroup):
|
||||
name="Frame Thickness", size=3, default=[0.035] * 3, subtype="TRANSLATION"
|
||||
)
|
||||
|
||||
# Material properties
|
||||
lining_material: bpy.props.EnumProperty(name="Lining Material", items=get_materials, options=set())
|
||||
framing_material: bpy.props.EnumProperty(name="Framing Material", items=get_materials, options=set())
|
||||
glazing_material: bpy.props.EnumProperty(name="Glazing Material", items=get_materials, options=set())
|
||||
|
||||
def get_general_kwargs(self, convert_to_project_units=False):
|
||||
kwargs = {
|
||||
"window_type": self.window_type,
|
||||
|
||||
@@ -448,8 +448,13 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
for panel_i in range(number_of_panels):
|
||||
cols[panel_i + 1].prop(props, prop, index=panel_i, text="")
|
||||
|
||||
update_window_modifier_bmesh(context)
|
||||
self.layout.use_property_split = True
|
||||
self.layout.label(text="Material Properties")
|
||||
self.layout.prop(props, "lining_material")
|
||||
self.layout.prop(props, "framing_material", text="Panel Material")
|
||||
self.layout.prop(props, "glazing_material")
|
||||
|
||||
update_window_modifier_bmesh(context)
|
||||
else:
|
||||
row.operator("bim.enable_editing_window", icon="GREASEPENCIL", text="")
|
||||
row.operator("bim.remove_window", icon="X", text="")
|
||||
@@ -492,7 +497,6 @@ class BIM_PT_window(bpy.types.Panel):
|
||||
prop_value = panel_props[prop_name][panel_i]
|
||||
r.label(text=str(prop_value))
|
||||
r = cols[panel_i + 1].row()
|
||||
|
||||
else:
|
||||
row = self.layout.row()
|
||||
row.label(text="No Window Found")
|
||||
|
||||
@@ -73,7 +73,7 @@ def update_window_modifier_representation(context: bpy.types.Context) -> None:
|
||||
}
|
||||
representation_data["panel_properties"].append(panel_data)
|
||||
|
||||
previously_active_context = tool.Geometry.get_active_representation_context(obj)
|
||||
active_context = tool.Geometry.get_active_representation_context(obj)
|
||||
|
||||
# ELEVATION_VIEW representation
|
||||
profile = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Profile", "ELEVATION_VIEW")
|
||||
@@ -88,8 +88,25 @@ def update_window_modifier_representation(context: bpy.types.Context) -> None:
|
||||
# (Model/Body defined only BEFORE Plan/Body to prevent #2744)
|
||||
body = ifcopenshell.util.representation.get_context(ifc_file, "Model", "Body", "MODEL_VIEW")
|
||||
representation_data["context"] = body
|
||||
representation_data["part_of_product"] = ifcopenshell.util.representation.get_part_of_product(element, body)
|
||||
model_representation = ifcopenshell.api.run("geometry.add_window_representation", ifc_file, **representation_data)
|
||||
representation_data["part_of_product"] = None
|
||||
tool.Model.replace_object_ifc_representation(body, obj, model_representation)
|
||||
if fallback_material := (int(props.lining_material) or int(props.framing_material) or int(props.glazing_material)):
|
||||
ifcopenshell.api.material.set_shape_aspect_constituents(
|
||||
ifc_file,
|
||||
element=element,
|
||||
context=body,
|
||||
materials={
|
||||
"Lining": tool.Ifc.get().by_id(int(props.lining_material) or fallback_material),
|
||||
"Framing": tool.Ifc.get().by_id(int(props.framing_material) or fallback_material),
|
||||
"Glazing": tool.Ifc.get().by_id(int(props.glazing_material) or fallback_material),
|
||||
},
|
||||
)
|
||||
elif material := ifcopenshell.util.element.get_material(element):
|
||||
ifcopenshell.api.material.unassign_material(ifc_file, products=[element])
|
||||
if not material.is_a("IfcMaterial") and not ifc_file.get_total_inverses(material):
|
||||
ifcopenshell.api.material.remove_material_set(ifc_file, material=material)
|
||||
|
||||
# PLAN_VIEW representation
|
||||
plan = ifcopenshell.util.representation.get_context(ifc_file, "Plan", "Body", "PLAN_VIEW")
|
||||
@@ -100,24 +117,15 @@ def update_window_modifier_representation(context: bpy.types.Context) -> None:
|
||||
)
|
||||
tool.Model.replace_object_ifc_representation(plan, obj, plan_representation)
|
||||
|
||||
# adding switch representation at the end instead of changing order of representations
|
||||
# to prevent #2744
|
||||
if tool.Geometry.get_active_representation_context(obj) != previously_active_context:
|
||||
previously_active_representation = ifcopenshell.util.representation.get_representation(
|
||||
element,
|
||||
previously_active_context.ContextType,
|
||||
previously_active_context.ContextIdentifier,
|
||||
previously_active_context.TargetView,
|
||||
)
|
||||
bonsai.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=previously_active_representation,
|
||||
should_reload=True,
|
||||
is_global=True,
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
bonsai.core.geometry.switch_representation(
|
||||
tool.Ifc,
|
||||
tool.Geometry,
|
||||
obj=obj,
|
||||
representation=ifcopenshell.util.representation.get_representation(element, active_context),
|
||||
should_reload=True,
|
||||
is_global=True,
|
||||
should_sync_changes_first=True,
|
||||
)
|
||||
|
||||
# type attributes
|
||||
if tool.Ifc.get_schema() != "IFC2X3":
|
||||
|
||||
Reference in New Issue
Block a user