You can now delete unit assignments

This commit is contained in:
Dion Moult
2021-08-06 14:11:08 +10:00
parent 4ccadc4f36
commit 326e7e591f
5 changed files with 53 additions and 2 deletions
@@ -17,6 +17,8 @@ class Data:
if not file:
return
cls.file = file
cls.unit_assignment = []
cls.units = {}
unit_assignment = cls.file.by_type("IfcUnitAssignment")
if not unit_assignment:
return
@@ -0,0 +1,18 @@
import ifcopenshell.util.element
class Usecase():
def __init__(self, file, **settings):
self.file = file
self.settings = {"unit": None}
for key, value in settings.items():
self.settings[key] = value
def execute(self):
unit_assignment = self.file.by_type("IfcUnitAssignment")[0]
units = list(unit_assignment.Units)
units.remove(self.settings["unit"])
if not units:
return
unit_assignment.Units = units
ifcopenshell.util.element.remove_deep(self.file, self.settings["unit"])