mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Element get_psets utility now returns the pset ID for convenience.
This commit is contained in:
@@ -28,6 +28,7 @@ def get_property_definition(definition):
|
||||
for prop in range(4, len(definition)):
|
||||
if definition[prop] is not None:
|
||||
props[definition.attribute_name(prop)] = definition[prop]
|
||||
props["id"] = definition.id()
|
||||
return props
|
||||
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ class TestGetPsetsIFC4(test.bootstrap.IFC4):
|
||||
assert subject.get_psets(element) == {}
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
|
||||
assert subject.get_psets(element) == {"name": {"a": "b"}}
|
||||
assert subject.get_psets(element) == {"name": {"a": "b", "id": 2}}
|
||||
|
||||
def test_getting_the_psets_of_a_product_type_as_a_dictionary(self):
|
||||
type_element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
assert subject.get_psets(type_element) == {}
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=type_element, name="name")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"x": "y"})
|
||||
assert subject.get_psets(type_element) == {"name": {"x": "y"}}
|
||||
assert subject.get_psets(type_element) == {"name": {"x": "y", "id": 2}}
|
||||
|
||||
def test_getting_psets_from_an_element_which_cannot_have_psets(self):
|
||||
assert subject.get_psets(self.file.create_entity("IfcPerson")) == {}
|
||||
@@ -28,18 +28,18 @@ class TestGetPropertyDefinitionIFC4(test.bootstrap.IFC4):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
pset = ifcopenshell.api.run("pset.add_pset", self.file, product=element, name="name")
|
||||
ifcopenshell.api.run("pset.edit_pset", self.file, pset=pset, properties={"a": "b"})
|
||||
assert subject.get_property_definition(pset) == {"a": "b"}
|
||||
assert subject.get_property_definition(pset) == {"a": "b", "id": 2}
|
||||
|
||||
def test_getting_the_properties_of_a_qto(self):
|
||||
element = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", self.file, product=element, name="name")
|
||||
ifcopenshell.api.run("pset.edit_qto", self.file, qto=qto, properties={"x": 42})
|
||||
assert subject.get_property_definition(qto) == {"x": 42}
|
||||
assert subject.get_property_definition(qto) == {"x": 42, "id": 2}
|
||||
|
||||
def test_getting_the_properties_of_a_predefined_pset(self):
|
||||
pset = self.file.create_entity("IfcDoorLiningProperties", ifcopenshell.guid.new())
|
||||
pset.LiningDepth = 42
|
||||
assert subject.get_property_definition(pset) == {"LiningDepth": 42}
|
||||
assert subject.get_property_definition(pset) == {"LiningDepth": 42, "id": 1}
|
||||
|
||||
|
||||
class TestGetQuantitiesIFC4(test.bootstrap.IFC4):
|
||||
|
||||
Reference in New Issue
Block a user