mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 18:16:40 +00:00
Fix #1889. Allow explicitly overriding data types when editing psets.
This commit is contained in:
@@ -38,6 +38,8 @@ class Usecase:
|
||||
value = self.settings["properties"][prop.Name]
|
||||
if value is None:
|
||||
prop.NominalValue = None
|
||||
elif isinstance(value, ifcopenshell.entity_instance):
|
||||
prop.NominalValue = value
|
||||
else:
|
||||
primary_measure_type = self.get_primary_measure_type(prop.Name, old_value=prop.NominalValue, new_value=value)
|
||||
prop.NominalValue = self.file.create_entity(primary_measure_type, value)
|
||||
|
||||
@@ -124,6 +124,30 @@ class TestEditPset(test.bootstrap.IFC4):
|
||||
assert pset.HasProperties[0].NominalValue.is_a("IfcContextDependentMeasure")
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue == 34
|
||||
|
||||
def test_editing_properties_with_an_explicit_type(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
"MyCustom": self.file.createIfcLabel("True"),
|
||||
},
|
||||
)
|
||||
ifcopenshell.api.run(
|
||||
"pset.edit_pset",
|
||||
self.file,
|
||||
pset=pset,
|
||||
properties={
|
||||
"MyCustom": self.file.createIfcBoolean(True),
|
||||
},
|
||||
)
|
||||
pset = element.IsDefinedBy[0].RelatingPropertyDefinition
|
||||
assert pset.HasProperties[0].Name == "MyCustom"
|
||||
assert pset.HasProperties[0].NominalValue.is_a("IfcBoolean")
|
||||
assert pset.HasProperties[0].NominalValue.wrappedValue is True
|
||||
|
||||
def test_editing_properties_of_non_rooted_elements(self):
|
||||
element = self.file.createIfcMaterial()
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="Foo_Bar")
|
||||
|
||||
Reference in New Issue
Block a user