mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-16 21:42:19 +00:00
move prop check
This commit is contained in:
committed by
Thomas Krijnen
parent
375f4f2a86
commit
1acc743370
@@ -174,20 +174,31 @@ class Usecase:
|
|||||||
self.psetqto = ifcopenshell.util.pset.get_template(self.file.schema)
|
self.psetqto = ifcopenshell.util.pset.get_template(self.file.schema)
|
||||||
self.pset_template = self.psetqto.get_by_name(self.settings["pset"].Name)
|
self.pset_template = self.psetqto.get_by_name(self.settings["pset"].Name)
|
||||||
|
|
||||||
|
def _has_property(self, prop) -> bool:
|
||||||
|
"""
|
||||||
|
Checks if the property already exists
|
||||||
|
"""
|
||||||
|
return prop.Name in self.settings["properties"]
|
||||||
|
|
||||||
# TODO - Add support for changing property types?
|
# TODO - Add support for changing property types?
|
||||||
# For example - IfcPropertyEnumeratedValue to
|
# For example - IfcPropertyEnumeratedValue to
|
||||||
# IfcPropertySingleValue. Or maybe the user should
|
# IfcPropertySingleValue. Or maybe the user should
|
||||||
# just delete the property first? - vulevukusej
|
# just delete the property first? - vulevukusej
|
||||||
def update_existing_properties(self):
|
def update_existing_properties(self):
|
||||||
for prop in self.get_properties():
|
for prop in self.get_properties():
|
||||||
|
if not self._has_property(prop):
|
||||||
|
continue
|
||||||
|
|
||||||
if prop.is_a("IfcPropertyEnumeratedValue"):
|
if prop.is_a("IfcPropertyEnumeratedValue"):
|
||||||
self.update_existing_enum(prop)
|
self.update_existing_enum(prop)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.update_existing_property(prop)
|
self.update_existing_property(prop)
|
||||||
|
|
||||||
def update_existing_enum(self, prop):
|
def update_existing_enum(self, prop):
|
||||||
if prop.Name not in self.settings["properties"]:
|
"""
|
||||||
return
|
NOTE: assumes the prop exists
|
||||||
|
"""
|
||||||
value = self.settings["properties"][prop.Name]
|
value = self.settings["properties"][prop.Name]
|
||||||
unit, value = self.unpack_unit_value(value)
|
unit, value = self.unpack_unit_value(value)
|
||||||
if isinstance(value, list):
|
if isinstance(value, list):
|
||||||
@@ -215,8 +226,9 @@ class Usecase:
|
|||||||
del self.settings["properties"][prop.Name]
|
del self.settings["properties"][prop.Name]
|
||||||
|
|
||||||
def update_existing_property(self, prop):
|
def update_existing_property(self, prop):
|
||||||
if prop.Name not in self.settings["properties"]:
|
"""
|
||||||
return
|
NOTE: assumes the prop exists
|
||||||
|
"""
|
||||||
value = self.settings["properties"][prop.Name]
|
value = self.settings["properties"][prop.Name]
|
||||||
unit, value = self.unpack_unit_value(value)
|
unit, value = self.unpack_unit_value(value)
|
||||||
if value is None:
|
if value is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user