mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 02:02:22 +00:00
Add support for IfcTester and predefined properties
This commit is contained in:
@@ -464,7 +464,10 @@ class Property(Facet):
|
||||
for prop_entity in self.get_properties(pset_entity):
|
||||
if prop_entity.Name not in props[pset_name].keys():
|
||||
continue
|
||||
if prop_entity.is_a("IfcPropertySingleValue"):
|
||||
if not isinstance(prop_entity, ifcopenshell.entity_instance):
|
||||
# Predefined properties are special :(
|
||||
pass
|
||||
elif prop_entity.is_a("IfcPropertySingleValue"):
|
||||
data_type = prop_entity.NominalValue.is_a()
|
||||
|
||||
if data_type != self.measure:
|
||||
@@ -640,6 +643,12 @@ class Property(Facet):
|
||||
return pset.Quantities
|
||||
elif pset.is_a("IfcMaterialProperties") or pset.is_a("IfcProfileProperties"):
|
||||
return pset.Properties
|
||||
elif pset.is_a("IfcPreDefinedPropertySet"):
|
||||
return [
|
||||
type("", (object,), {"Name": k, "Value": v})()
|
||||
for k, v in pset.get_info().items()
|
||||
if not isinstance(v, ifcopenshell.entity_instance)
|
||||
]
|
||||
|
||||
|
||||
class Material(Facet):
|
||||
|
||||
@@ -1076,6 +1076,29 @@ class TestProperty:
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLabel")
|
||||
run("Reference properties are treated as objects and not supported", facet=facet, inst=element, expected=False)
|
||||
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcDoor")
|
||||
pset = ifc.create_entity(
|
||||
"IfcDoorPanelProperties",
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
Name="Foo_Bar",
|
||||
PanelOperation="SWINGING",
|
||||
PanelPosition="LEFT",
|
||||
)
|
||||
ifc.create_entity(
|
||||
"IfcRelDefinesByProperties",
|
||||
GlobalId=ifcopenshell.guid.new(),
|
||||
RelatedObjects=[element],
|
||||
RelatingPropertyDefinition=pset,
|
||||
)
|
||||
facet = Property(
|
||||
propertySet="Foo_Bar", name="PanelOperation", value="SWINGING", measure="IfcDoorPanelOperationEnum"
|
||||
)
|
||||
run("Predefined properties are supported but discouraged 1/2", facet=facet, inst=element, expected=True)
|
||||
facet = Property(
|
||||
propertySet="Foo_Bar", name="PanelOperation", value="SWONGING", measure="IfcDoorPanelOperationEnum"
|
||||
)
|
||||
run("Predefined properties are supported but discouraged 2/2", facet=facet, inst=element, expected=False)
|
||||
|
||||
facet = Property(propertySet="Foo_Bar", name="Foo", measure="IfcLengthMeasure")
|
||||
element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
|
||||
qto = ifcopenshell.api.run("pset.add_qto", ifc, product=element, name="Foo_Bar")
|
||||
|
||||
Reference in New Issue
Block a user