Fixed Door modifier initial opening problem #2784

- add check of OverallHeight and OverallWidth for creating openings for doors and windows;
- OverallHeight, OverallWidth update for all the occurences of the type for doors and windows;
- new tool.Ifc method - get_all_element_occurences
This commit is contained in:
Andrej730
2023-02-18 17:11:04 +05:00
parent 57d18a0644
commit 4b15b02ac8
6 changed files with 53 additions and 10 deletions
@@ -105,9 +105,16 @@ def update_door_modifier_representation(context):
is_global=True,
should_sync_changes_first=True,
)
# type attributes
element.OperationType = props.door_type
# occurences attributes
occurences = tool.Ifc.get_all_element_occurences(element)
for occurence in occurences:
occurence.OverallWidth = props.overall_width
occurence.OverallHeight = props.overall_height
update_simple_openings(element, props.overall_width, props.overall_height)
@@ -223,6 +223,15 @@ class FilledOpeningGenerator:
return shape_builder.get_representation(context, [extrusion])
x, y, z = filling_obj.dimensions
# Windows and doors can have a casing that overlaps the wall
# but shouldn't affect the size of the opening.
# So we shouldn't use object dimensions in that case. More: #2784
# Just keeping it for windows and doors for now to be safe
if filling.is_a() in ["IfcWindow", "IfcDoor"]:
x = filling.OverallWidth or x
z = filling.OverallHeight or z
extrusion = shape_builder.extrude(
shape_builder.rectangle(size=Vector([x / unit_scale, 0.0, z / unit_scale])),
magnitude=thickness / unit_scale,
@@ -35,6 +35,7 @@ from blenderbim.bim.module.model.prop import store_cursor_position
from mathutils import Vector, Matrix
from bpy_extras.object_utils import AddObjectHelper
from . import prop
import json
def select_and_activate_single_object(context, obj):
@@ -144,6 +145,15 @@ class AddConstrTypeInstance(bpy.types.Operator):
# Update required as core.type.assign_type may change obj.data
context.view_layer.update()
# set occurences properties for the types defined with modifiers
if instance_class in ["IfcWindow", "IfcDoor"]:
pset_name = f'BBIM_{instance_class[3:]}'
bbim_pset = ifcopenshell.util.element.get_psets(element).get(pset_name, None)
if bbim_pset:
bbim_prop_data = json.loads(bbim_pset['Data'])
element.OverallWidth = bbim_prop_data['overall_width']
element.OverallHeight = bbim_prop_data['overall_height']
if (
building_obj
and building_element
@@ -39,15 +39,7 @@ from mathutils import Vector
def update_simple_openings(element, opening_width, opening_height):
element_type = None
ifc_file = tool.Ifc.get()
if element.is_a("IfcElementType"):
element_type = element
fillings = ifcopenshell.util.element.get_types(element_type)
else:
element_type = ifcopenshell.util.element.get_type(element)
if element_type:
fillings = ifcopenshell.util.element.get_types(element_type)
else:
fillings = [element]
fillings = tool.Ifc.get_all_element_occurences(element)
voided_objs = set()
has_replaced_opening_representation = False
@@ -176,8 +168,15 @@ def update_window_modifier_representation(context):
should_sync_changes_first=True,
)
# type attributes
element.PartitioningType = props.window_type
# occurences attributes
occurences = tool.Ifc.get_all_element_occurences(element)
for occurence in occurences:
occurence.OverallWidth = props.overall_width
occurence.OverallHeight = props.overall_height
update_simple_openings(element, props.overall_width, props.overall_height)
+1
View File
@@ -346,6 +346,7 @@ class Ifc:
def run(cls, command, **kwargs): pass
def set(cls, ifc): pass
def unlink(cls, element=None, obj=None): pass
def get_all_element_occurences(cls, element): pass
@interface
+17
View File
@@ -100,6 +100,23 @@ class Ifc(blenderbim.core.tool.Ifc):
def unlink(cls, element=None, obj=None):
IfcStore.unlink_element(element, obj)
@classmethod
def get_all_element_occurences(cls, element):
if element.is_a("IfcElementType"):
element_type = element
occurences = ifcopenshell.util.element.get_types(element_type)
else:
element_type = ifcopenshell.util.element.get_type(element)
if element_type:
occurences = ifcopenshell.util.element.get_types(element_type)
else:
occurences = [element]
return occurences
@classmethod
def unlink(cls, element=None, obj=None):
IfcStore.unlink_element(element, obj)
class Operator:
def execute(self, context):
IfcStore.execute_ifc_operator(self, context)