mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Support IDS uri/use/instructions for property facets
This commit is contained in:
@@ -824,7 +824,7 @@ class property(facet):
|
||||
message = "%(location)sproperty '%(name)s' in '%(propertySet)s' with a value %(value)s"
|
||||
|
||||
@staticmethod
|
||||
def create(location="any", propertySet=None, name=None, value=None):
|
||||
def create(propertySet="Property_Set", name="PropertyName", value=None, location="any", measure=None, uri=None, use=None, instructions=None):
|
||||
"""Create a property facet that can be added to applicability or requirements of IDS specification.
|
||||
|
||||
:param location: Where to check for the parameter. One of "any"|"instance"|"type", defaults to "any"
|
||||
@@ -839,13 +839,14 @@ class property(facet):
|
||||
:rtype: property
|
||||
"""
|
||||
inst = property()
|
||||
inst.location = location
|
||||
inst.propertySet = propertySet
|
||||
inst.name = name
|
||||
inst.value = value
|
||||
# cls.attributes = {'@location': location} # 'type', 'instance', 'any'
|
||||
# BUG '@href': 'http://identifier.buildingsmart.org/uri/buildingsmart/ifc-4.3/prop/FireRating', #https://identifier.buildingsmart.org/uri/something
|
||||
# BUG 'instructions': 'Please add the desired rating.',
|
||||
inst.location = location
|
||||
inst.measure = measure
|
||||
inst.uri = uri
|
||||
inst.use = use
|
||||
inst.instructions = instructions
|
||||
return inst
|
||||
|
||||
def asdict(self):
|
||||
@@ -854,15 +855,23 @@ class property(facet):
|
||||
:return: Xmlschema compliant dictionary.
|
||||
:rtype: dict
|
||||
"""
|
||||
fac_dict = {
|
||||
results = {
|
||||
"@location": self.location,
|
||||
"propertySet": parameter_asdict(self.propertySet),
|
||||
"name": parameter_asdict(self.name),
|
||||
"value": parameter_asdict(self.value),
|
||||
# "instructions": "SAMPLE_INSTRUCTIONS",
|
||||
# TODO '@href': 'http://identifier.buildingsmart.org/uri/buildingsmart/ifc-4.3/prop/FireRating', #https://identifier.buildingsmart.org/uri/something
|
||||
}
|
||||
return fac_dict
|
||||
if self.value:
|
||||
results["value"] = parameter_asdict(self.value)
|
||||
if self.measure:
|
||||
results["@measure"] = self.measure
|
||||
if self.uri:
|
||||
results["@uri"] = self.uri
|
||||
if self.use:
|
||||
results["@use"] = self.use
|
||||
if self.instructions:
|
||||
results["@instructions"] = self.instructions
|
||||
# TODO '@href': 'http://identifier.buildingsmart.org/uri/buildingsmart/ifc-4.3/prop/FireRating', #https://identifier.buildingsmart.org/uri/something
|
||||
return results
|
||||
|
||||
def __call__(self, inst, logger):
|
||||
"""Validate an ifc instance against that property facet.
|
||||
|
||||
@@ -602,14 +602,24 @@ class TestIdsAuthoring(unittest.TestCase):
|
||||
assert bool(facet(wall)) is True
|
||||
assert bool(facet(wall_type)) is True
|
||||
|
||||
def test_property_create(self):
|
||||
p = ids.property.create(
|
||||
location="any", propertySet="Test_PropertySet", name="Test_Parameter", value="Test_Value"
|
||||
)
|
||||
self.assertEqual(p.location, "any")
|
||||
self.assertEqual(p.propertySet, "Test_PropertySet")
|
||||
self.assertEqual(p.name, "Test_Parameter")
|
||||
self.assertEqual(p.value, "Test_Value")
|
||||
def test_creating_a_property_facet(self):
|
||||
facet = ids.property.create()
|
||||
assert facet.asdict() == {
|
||||
"propertySet": {"simpleValue": "Property_Set"},
|
||||
"name": {"simpleValue": "PropertyName"},
|
||||
"@location": "any",
|
||||
}
|
||||
facet = ids.property.create(propertySet="propertySet", name="name", value="value", location="instance", measure="String", uri="https://test.com", use="required", instructions="instructions")
|
||||
assert facet.asdict() == {
|
||||
"propertySet": {"simpleValue": "propertySet"},
|
||||
"name": {"simpleValue": "name"},
|
||||
"value": {"simpleValue": "value"},
|
||||
"@location": "instance",
|
||||
"@measure": "String",
|
||||
"@uri": "https://test.com",
|
||||
"@use": "required",
|
||||
"@instructions": "instructions",
|
||||
}
|
||||
|
||||
def test_material_create(self):
|
||||
m = ids.material.create(location="any", value="Test_Value")
|
||||
|
||||
Reference in New Issue
Block a user