Fixed issue changing type of object creating opening in an aggregate

More: https://community.osarch.org/discussion/1888/error-after-trying-to-change-a-window-type-whose-opening-is-applied-to-an-aggregate#latest

A bit related to #3973 in case if it will be resolved
This commit is contained in:
Andrej730
2023-12-25 11:49:06 +05:00
parent 7f4c3d629b
commit 796dddaa7a
@@ -181,7 +181,7 @@ class FilledOpeningGenerator:
return return
opening = filling.FillsVoids[0].RelatingOpeningElement opening = filling.FillsVoids[0].RelatingOpeningElement
voided_obj = tool.Ifc.get_object(opening.VoidsElements[0].RelatingBuildingElement) voided_element = opening.VoidsElements[0].RelatingBuildingElement
opening_rep = ifcopenshell.util.representation.get_representation(opening, "Model", "Body", "MODEL_VIEW") opening_rep = ifcopenshell.util.representation.get_representation(opening, "Model", "Body", "MODEL_VIEW")
ifcopenshell.api.run( ifcopenshell.api.run(
@@ -217,16 +217,22 @@ class FilledOpeningGenerator:
"geometry.assign_representation", tool.Ifc.get(), product=opening, representation=mapped_representation "geometry.assign_representation", tool.Ifc.get(), product=opening, representation=mapped_representation
) )
representation = tool.Ifc.get().by_id(voided_obj.data.BIMMeshProperties.ifc_definition_id) # update voided object representation or all it's parts if it's an aggregate
blenderbim.core.geometry.switch_representation( voided_elements = ifcopenshell.util.element.get_parts(voided_element) or [voided_element]
tool.Ifc, for voided_element in voided_elements:
tool.Geometry, voided_obj = tool.Ifc.get_object(voided_element)
obj=voided_obj, if not voided_obj.data:
representation=representation, continue
should_reload=True, representation = tool.Ifc.get().by_id(voided_obj.data.BIMMeshProperties.ifc_definition_id)
is_global=True, blenderbim.core.geometry.switch_representation(
should_sync_changes_first=False, tool.Ifc,
) tool.Geometry,
obj=voided_obj,
representation=representation,
should_reload=True,
is_global=True,
should_sync_changes_first=False,
)
def generate_opening_from_filling(self, filling, filling_obj): def generate_opening_from_filling(self, filling, filling_obj):
# Since openings are reused later, we give a default thickness of 1.2m # Since openings are reused later, we give a default thickness of 1.2m