mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 09:32:37 +00:00
Resolve #1773. IfcCSV now supports editing properties that were previously null.
This commit is contained in:
+22
-6
@@ -47,7 +47,7 @@ class IfcAttributeSetter:
|
|||||||
pset_name, prop = key.split(".", 1)
|
pset_name, prop = key.split(".", 1)
|
||||||
pset = IfcAttributeSetter.get_element_pset(element, pset_name)
|
pset = IfcAttributeSetter.get_element_pset(element, pset_name)
|
||||||
if pset:
|
if pset:
|
||||||
IfcAttributeSetter.set_pset_property(pset, prop, value)
|
IfcAttributeSetter.set_pset_property(ifc_file, pset, prop, value)
|
||||||
return element
|
return element
|
||||||
return element
|
return element
|
||||||
|
|
||||||
@@ -85,11 +85,27 @@ class IfcAttributeSetter:
|
|||||||
return relationship.RelatingPropertyDefinition
|
return relationship.RelatingPropertyDefinition
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def set_pset_property(pset, name, value):
|
def set_pset_property(ifc_file, pset, name, value):
|
||||||
for property in pset.HasProperties:
|
for property in pset.HasProperties:
|
||||||
if property.Name == name:
|
if property.Name != name:
|
||||||
# In lieu of loading a map for data casting, we only have four
|
continue
|
||||||
# options, which this ugly method will determine.
|
|
||||||
|
# In lieu of loading a map for data casting, we only have four
|
||||||
|
# options, which this ugly method will determine.
|
||||||
|
if property.NominalValue is None:
|
||||||
|
if value.isnumeric():
|
||||||
|
property.NominalValue = ifc_file.createIfcInteger(int(value))
|
||||||
|
elif value.lower() in ["1", "true", "yes", "uh-huh"]:
|
||||||
|
property.NominalValue = ifc_file.createIfcBoolean(True)
|
||||||
|
elif value.lower() in ["0", "false", "no", "nope"]:
|
||||||
|
property.NominalValue = ifc_file.createIfcBoolean(False)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
value = float(value)
|
||||||
|
property.NominalValue = ifc_file.createIfcReal(value)
|
||||||
|
except:
|
||||||
|
property.NominalValue = ifc_file.createIfcLabel(str(value))
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
property.NominalValue.wrappedValue = str(value)
|
property.NominalValue.wrappedValue = str(value)
|
||||||
except:
|
except:
|
||||||
@@ -100,7 +116,7 @@ class IfcAttributeSetter:
|
|||||||
property.NominalValue.wrappedValue = int(value)
|
property.NominalValue.wrappedValue = int(value)
|
||||||
except:
|
except:
|
||||||
property.NominalValue.wrappedValue = (
|
property.NominalValue.wrappedValue = (
|
||||||
True if value.lower() in ["1", "t", "true", "yes", "y", "uh-huh"] else False
|
True if value.lower() in ["1", "true", "yes", "uh-huh"] else False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user