Files
IfcOpenShell/src/ifcopenshell-python/ifcopenshell/api/unit/remove_unit.py
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
766 B
Python
Raw Normal View History

import ifcopenshell.util.unit
2021-08-06 14:11:08 +10:00
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 = ifcopenshell.util.unit.get_unit_assignment(self.file)
if unit_assignment and self.settings["unit"] in unit_assignment.Units:
units = list(unit_assignment.Units)
units.remove(self.settings["unit"])
if units:
unit_assignment.Units = units
else:
self.file.remove(unit_assignment)
2021-08-06 14:11:08 +10:00
ifcopenshell.util.element.remove_deep(self.file, self.settings["unit"])