mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
You can now delete unit assignments
This commit is contained in:
@@ -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"])
|
||||
Reference in New Issue
Block a user