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,6 +217,12 @@ class FilledOpeningGenerator:
"geometry.assign_representation", tool.Ifc.get(), product=opening, representation=mapped_representation "geometry.assign_representation", tool.Ifc.get(), product=opening, representation=mapped_representation
) )
# update voided object representation or all it's parts if it's an aggregate
voided_elements = ifcopenshell.util.element.get_parts(voided_element) or [voided_element]
for voided_element in voided_elements:
voided_obj = tool.Ifc.get_object(voided_element)
if not voided_obj.data:
continue
representation = tool.Ifc.get().by_id(voided_obj.data.BIMMeshProperties.ifc_definition_id) representation = tool.Ifc.get().by_id(voided_obj.data.BIMMeshProperties.ifc_definition_id)
blenderbim.core.geometry.switch_representation( blenderbim.core.geometry.switch_representation(
tool.Ifc, tool.Ifc,