Copying elements with openings now also copies openings

This commit is contained in:
Dion Moult
2022-10-05 19:44:32 +11:00
parent d525dfa46f
commit e97d427e9f
4 changed files with 26 additions and 4 deletions
@@ -17,6 +17,7 @@
# along with IfcOpenShell. If not, see <http://www.gnu.org/licenses/>.
import ifcopenshell
import ifcopenshell.util.system
import ifcopenshell.util.element
@@ -69,6 +70,17 @@ class Usecase:
continue
elif inverse.is_a("IfcRelDefinesByType") and inverse.RelatingType == from_element:
continue
elif inverse.is_a("IfcRelVoidsElement") and inverse.RelatingBuildingElement == from_element:
opening = inverse.RelatedOpeningElement
new_opening = ifcopenshell.api.run("root.copy_class", self.file, product=opening)
new_opening.VoidsElements[0].RelatingBuildingElement = to_element
if new_opening.ObjectPlacement and new_opening.ObjectPlacement.is_a("IfcLocalPlacement"):
if to_element.ObjectPlacement:
new_opening.ObjectPlacement.PlacementRelTo = to_element.ObjectPlacement
# For now, we do copy opening representations
new_opening.Representation = ifcopenshell.util.element.copy_deep(
self.file, opening.Representation
)
elif inverse.is_a("IfcRelFillsElement"):
continue
elif inverse.is_a("IfcRelConnectsPathElements"):