mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
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:
@@ -106,8 +106,15 @@ def update_door_modifier_representation(context):
|
|||||||
should_sync_changes_first=True,
|
should_sync_changes_first=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# type attributes
|
||||||
element.OperationType = props.door_type
|
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)
|
update_simple_openings(element, props.overall_width, props.overall_height)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -223,6 +223,15 @@ class FilledOpeningGenerator:
|
|||||||
return shape_builder.get_representation(context, [extrusion])
|
return shape_builder.get_representation(context, [extrusion])
|
||||||
|
|
||||||
x, y, z = filling_obj.dimensions
|
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(
|
extrusion = shape_builder.extrude(
|
||||||
shape_builder.rectangle(size=Vector([x / unit_scale, 0.0, z / unit_scale])),
|
shape_builder.rectangle(size=Vector([x / unit_scale, 0.0, z / unit_scale])),
|
||||||
magnitude=thickness / 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 mathutils import Vector, Matrix
|
||||||
from bpy_extras.object_utils import AddObjectHelper
|
from bpy_extras.object_utils import AddObjectHelper
|
||||||
from . import prop
|
from . import prop
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def select_and_activate_single_object(context, obj):
|
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
|
# Update required as core.type.assign_type may change obj.data
|
||||||
context.view_layer.update()
|
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 (
|
if (
|
||||||
building_obj
|
building_obj
|
||||||
and building_element
|
and building_element
|
||||||
|
|||||||
@@ -39,15 +39,7 @@ from mathutils import Vector
|
|||||||
def update_simple_openings(element, opening_width, opening_height):
|
def update_simple_openings(element, opening_width, opening_height):
|
||||||
element_type = None
|
element_type = None
|
||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
if element.is_a("IfcElementType"):
|
fillings = tool.Ifc.get_all_element_occurences(element)
|
||||||
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]
|
|
||||||
|
|
||||||
voided_objs = set()
|
voided_objs = set()
|
||||||
has_replaced_opening_representation = False
|
has_replaced_opening_representation = False
|
||||||
@@ -176,8 +168,15 @@ def update_window_modifier_representation(context):
|
|||||||
should_sync_changes_first=True,
|
should_sync_changes_first=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# type attributes
|
||||||
element.PartitioningType = props.window_type
|
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)
|
update_simple_openings(element, props.overall_width, props.overall_height)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ class Ifc:
|
|||||||
def run(cls, command, **kwargs): pass
|
def run(cls, command, **kwargs): pass
|
||||||
def set(cls, ifc): pass
|
def set(cls, ifc): pass
|
||||||
def unlink(cls, element=None, obj=None): pass
|
def unlink(cls, element=None, obj=None): pass
|
||||||
|
def get_all_element_occurences(cls, element): pass
|
||||||
|
|
||||||
|
|
||||||
@interface
|
@interface
|
||||||
|
|||||||
@@ -100,6 +100,23 @@ class Ifc(blenderbim.core.tool.Ifc):
|
|||||||
def unlink(cls, element=None, obj=None):
|
def unlink(cls, element=None, obj=None):
|
||||||
IfcStore.unlink_element(element, obj)
|
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:
|
class Operator:
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
IfcStore.execute_ifc_operator(self, context)
|
IfcStore.execute_ifc_operator(self, context)
|
||||||
|
|||||||
Reference in New Issue
Block a user