mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Don't burn CPU cycles for updating parametric windows
This commit is contained in:
@@ -27,6 +27,7 @@ from bpy.types import PropertyGroup, NodeTree
|
|||||||
from math import pi, radians
|
from math import pi, radians
|
||||||
from bonsai.bim.module.model.decorator import WallAxisDecorator, SlabDirectionDecorator
|
from bonsai.bim.module.model.decorator import WallAxisDecorator, SlabDirectionDecorator
|
||||||
from bonsai.bim.module.model.door import update_door_modifier_bmesh
|
from bonsai.bim.module.model.door import update_door_modifier_bmesh
|
||||||
|
from bonsai.bim.module.model.window import update_window_modifier_bmesh
|
||||||
from typing import TYPE_CHECKING, Literal, get_args
|
from typing import TYPE_CHECKING, Literal, get_args
|
||||||
|
|
||||||
|
|
||||||
@@ -130,6 +131,10 @@ def update_door(self, context):
|
|||||||
update_door_modifier_bmesh(context)
|
update_door_modifier_bmesh(context)
|
||||||
|
|
||||||
|
|
||||||
|
def update_window(self, context):
|
||||||
|
update_window_modifier_bmesh(context)
|
||||||
|
|
||||||
|
|
||||||
class BIMModelProperties(PropertyGroup):
|
class BIMModelProperties(PropertyGroup):
|
||||||
ifc_class: bpy.props.EnumProperty(items=get_ifc_class, name="Construction Class", update=update_ifc_class)
|
ifc_class: bpy.props.EnumProperty(items=get_ifc_class, name="Construction Class", update=update_ifc_class)
|
||||||
relating_type_id: bpy.props.EnumProperty(
|
relating_type_id: bpy.props.EnumProperty(
|
||||||
@@ -439,6 +444,7 @@ def window_type_prop_update(self, context):
|
|||||||
number_of_panels, panels_data = self.window_types_panels[self.window_type]
|
number_of_panels, panels_data = self.window_types_panels[self.window_type]
|
||||||
self.first_mullion_offset, self.second_mullion_offset = panels_data[0]
|
self.first_mullion_offset, self.second_mullion_offset = panels_data[0]
|
||||||
self.first_transom_offset, self.second_transom_offset = panels_data[1]
|
self.first_transom_offset, self.second_transom_offset = panels_data[1]
|
||||||
|
update_window(self, context)
|
||||||
|
|
||||||
|
|
||||||
# default prop values are in mm and converted later
|
# default prop values are in mm and converted later
|
||||||
@@ -475,50 +481,66 @@ class BIMWindowProperties(PropertyGroup):
|
|||||||
window_type: bpy.props.EnumProperty(
|
window_type: bpy.props.EnumProperty(
|
||||||
name="Window Type", items=window_types, default="SINGLE_PANEL", update=window_type_prop_update
|
name="Window Type", items=window_types, default="SINGLE_PANEL", update=window_type_prop_update
|
||||||
)
|
)
|
||||||
overall_height: bpy.props.FloatProperty(name="Overall Height", default=0.9, subtype="DISTANCE")
|
overall_height: bpy.props.FloatProperty(
|
||||||
overall_width: bpy.props.FloatProperty(name="Overall Width", default=0.6, subtype="DISTANCE")
|
name="Overall Height", default=0.9, subtype="DISTANCE", update=update_window
|
||||||
|
)
|
||||||
|
overall_width: bpy.props.FloatProperty(name="Overall Width", default=0.6, subtype="DISTANCE", update=update_window)
|
||||||
|
|
||||||
# lining properties
|
# lining properties
|
||||||
lining_depth: bpy.props.FloatProperty(name="Lining Depth", default=0.050, subtype="DISTANCE")
|
lining_depth: bpy.props.FloatProperty(name="Lining Depth", default=0.050, subtype="DISTANCE", update=update_window)
|
||||||
lining_thickness: bpy.props.FloatProperty(name="Lining Thickness", default=0.050, subtype="DISTANCE")
|
lining_thickness: bpy.props.FloatProperty(
|
||||||
lining_offset: bpy.props.FloatProperty(name="Lining Offset", default=0.050, subtype="DISTANCE")
|
name="Lining Thickness", default=0.050, subtype="DISTANCE", update=update_window
|
||||||
|
)
|
||||||
|
lining_offset: bpy.props.FloatProperty(
|
||||||
|
name="Lining Offset", default=0.050, subtype="DISTANCE", update=update_window
|
||||||
|
)
|
||||||
lining_to_panel_offset_x: bpy.props.FloatProperty(
|
lining_to_panel_offset_x: bpy.props.FloatProperty(
|
||||||
name="Lining to Panel Offset X", default=0.025, subtype="DISTANCE"
|
name="Lining to Panel Offset X", default=0.025, subtype="DISTANCE", update=update_window
|
||||||
)
|
)
|
||||||
lining_to_panel_offset_y: bpy.props.FloatProperty(
|
lining_to_panel_offset_y: bpy.props.FloatProperty(
|
||||||
name="Lining to Panel Offset Y", default=0.025, subtype="DISTANCE"
|
name="Lining to Panel Offset Y", default=0.025, subtype="DISTANCE", update=update_window
|
||||||
|
)
|
||||||
|
mullion_thickness: bpy.props.FloatProperty(
|
||||||
|
name="Mullion Thickness", default=0.050, subtype="DISTANCE", update=update_window
|
||||||
)
|
)
|
||||||
mullion_thickness: bpy.props.FloatProperty(name="Mullion Thickness", default=0.050, subtype="DISTANCE")
|
|
||||||
first_mullion_offset: bpy.props.FloatProperty(
|
first_mullion_offset: bpy.props.FloatProperty(
|
||||||
name="First Mullion Offset",
|
name="First Mullion Offset",
|
||||||
description="Distance from the first lining to the first mullion center",
|
description="Distance from the first lining to the first mullion center",
|
||||||
default=0.3,
|
default=0.3,
|
||||||
subtype="DISTANCE",
|
subtype="DISTANCE",
|
||||||
|
update=update_window,
|
||||||
)
|
)
|
||||||
second_mullion_offset: bpy.props.FloatProperty(
|
second_mullion_offset: bpy.props.FloatProperty(
|
||||||
name="Second Mullion Offset",
|
name="Second Mullion Offset",
|
||||||
description="Distance from the first lining to the second mullion center",
|
description="Distance from the first lining to the second mullion center",
|
||||||
default=0.45,
|
default=0.45,
|
||||||
subtype="DISTANCE",
|
subtype="DISTANCE",
|
||||||
|
update=update_window,
|
||||||
|
)
|
||||||
|
transom_thickness: bpy.props.FloatProperty(
|
||||||
|
name="Transom Thickness", default=0.050, subtype="DISTANCE", update=update_window
|
||||||
)
|
)
|
||||||
transom_thickness: bpy.props.FloatProperty(name="Transom Thickness", default=0.050, subtype="DISTANCE")
|
|
||||||
first_transom_offset: bpy.props.FloatProperty(
|
first_transom_offset: bpy.props.FloatProperty(
|
||||||
name="First Transom Offset",
|
name="First Transom Offset",
|
||||||
description="Distance from the first lining to the first transom center",
|
description="Distance from the first lining to the first transom center",
|
||||||
default=0.3,
|
default=0.3,
|
||||||
subtype="DISTANCE",
|
subtype="DISTANCE",
|
||||||
|
update=update_window,
|
||||||
)
|
)
|
||||||
second_transom_offset: bpy.props.FloatProperty(
|
second_transom_offset: bpy.props.FloatProperty(
|
||||||
name="Second Transom Offset",
|
name="Second Transom Offset",
|
||||||
description="Distance from the first lining to the second transom center",
|
description="Distance from the first lining to the second transom center",
|
||||||
default=0.6,
|
default=0.6,
|
||||||
subtype="DISTANCE",
|
subtype="DISTANCE",
|
||||||
|
update=update_window,
|
||||||
)
|
)
|
||||||
|
|
||||||
# panel properties
|
# panel properties
|
||||||
frame_depth: bpy.props.FloatVectorProperty(name="Frame Depth", size=3, default=[0.035] * 3, subtype="TRANSLATION")
|
frame_depth: bpy.props.FloatVectorProperty(
|
||||||
|
name="Frame Depth", size=3, default=[0.035] * 3, subtype="TRANSLATION", update=update_window
|
||||||
|
)
|
||||||
frame_thickness: bpy.props.FloatVectorProperty(
|
frame_thickness: bpy.props.FloatVectorProperty(
|
||||||
name="Frame Thickness", size=3, default=[0.035] * 3, subtype="TRANSLATION"
|
name="Frame Thickness", size=3, default=[0.035] * 3, subtype="TRANSLATION", update=update_window
|
||||||
)
|
)
|
||||||
|
|
||||||
# Material properties
|
# Material properties
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ from bonsai.bim.module.model.data import (
|
|||||||
)
|
)
|
||||||
from bonsai.bim.module.model.prop import get_ifc_class
|
from bonsai.bim.module.model.prop import get_ifc_class
|
||||||
from bonsai.bim.module.model.stair import regenerate_stair_mesh
|
from bonsai.bim.module.model.stair import regenerate_stair_mesh
|
||||||
from bonsai.bim.module.model.window import update_window_modifier_bmesh
|
|
||||||
from bonsai.bim.module.model.railing import update_railing_modifier_bmesh
|
from bonsai.bim.module.model.railing import update_railing_modifier_bmesh
|
||||||
from bonsai.bim.module.model.roof import update_roof_modifier_bmesh
|
from bonsai.bim.module.model.roof import update_roof_modifier_bmesh
|
||||||
from collections.abc import Iterable
|
from collections.abc import Iterable
|
||||||
@@ -453,8 +452,6 @@ class BIM_PT_window(bpy.types.Panel):
|
|||||||
self.layout.prop(props, "lining_material")
|
self.layout.prop(props, "lining_material")
|
||||||
self.layout.prop(props, "framing_material", text="Panel Material")
|
self.layout.prop(props, "framing_material", text="Panel Material")
|
||||||
self.layout.prop(props, "glazing_material")
|
self.layout.prop(props, "glazing_material")
|
||||||
|
|
||||||
update_window_modifier_bmesh(context)
|
|
||||||
else:
|
else:
|
||||||
row.operator("bim.enable_editing_window", icon="GREASEPENCIL", text="")
|
row.operator("bim.enable_editing_window", icon="GREASEPENCIL", text="")
|
||||||
row.operator("bim.remove_window", icon="X", text="")
|
row.operator("bim.remove_window", icon="X", text="")
|
||||||
|
|||||||
@@ -108,15 +108,9 @@ def set_shape_aspect_constituents(
|
|||||||
ifcopenshell.api.material.assign_material(file, products=[element], material=material_set)
|
ifcopenshell.api.material.assign_material(file, products=[element], material=material_set)
|
||||||
|
|
||||||
styles = {n: ifcopenshell.util.representation.get_material_style(m, context) for n, m in materials.items()}
|
styles = {n: ifcopenshell.util.representation.get_material_style(m, context) for n, m in materials.items()}
|
||||||
print('styels are', styles)
|
|
||||||
representation = ifcopenshell.util.representation.get_representation(element, context=context)
|
representation = ifcopenshell.util.representation.get_representation(element, context=context)
|
||||||
print('rep is', representation)
|
|
||||||
representation = ifcopenshell.util.representation.resolve_representation(representation)
|
representation = ifcopenshell.util.representation.resolve_representation(representation)
|
||||||
print('rrep is', representation)
|
|
||||||
for item in representation.Items:
|
for item in representation.Items:
|
||||||
print('checking item', item)
|
|
||||||
if aspect := ifcopenshell.util.representation.get_item_shape_aspect(representation, item):
|
if aspect := ifcopenshell.util.representation.get_item_shape_aspect(representation, item):
|
||||||
print('found', aspect.Name)
|
|
||||||
if style := styles.get(aspect.Name, None):
|
if style := styles.get(aspect.Name, None):
|
||||||
print('... and correlating style', style)
|
|
||||||
ifcopenshell.api.style.assign_item_style(file, item=item, style=style)
|
ifcopenshell.api.style.assign_item_style(file, item=item, style=style)
|
||||||
|
|||||||
Reference in New Issue
Block a user