mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
You can now add and edit context dependent units including dimensional exponents
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import ifcopenshell.util.unit
|
||||
import ifcopenshell.util.element
|
||||
|
||||
|
||||
@@ -9,10 +10,12 @@ class Usecase():
|
||||
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
|
||||
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)
|
||||
ifcopenshell.util.element.remove_deep(self.file, self.settings["unit"])
|
||||
|
||||
Reference in New Issue
Block a user