mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Implement IDS uri/use/instructions for material facet
This commit is contained in:
@@ -979,7 +979,7 @@ class material(facet):
|
|||||||
message = "%(location)smaterial '%(value)s'"
|
message = "%(location)smaterial '%(value)s'"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create(location="any", value=None):
|
def create(value=None, location="any", uri=None, use=None, instructions=None):
|
||||||
"""Create a material facet that can be added to applicability or requirements of IDS specification.
|
"""Create a material 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"
|
:param location: Where to check for the parameter. One of "any"|"instance"|"type", defaults to "any"
|
||||||
@@ -990,11 +990,11 @@ class material(facet):
|
|||||||
:rtype: material
|
:rtype: material
|
||||||
"""
|
"""
|
||||||
inst = material()
|
inst = material()
|
||||||
inst.location = location
|
|
||||||
inst.value = value
|
inst.value = value
|
||||||
# TODO '@use': 'optional'
|
inst.location = location
|
||||||
# TODO '@href': 'https://identifier.buildingsmart.org/uri/something',
|
inst.uri = uri
|
||||||
# TODO 'instructions': 'Please add the desired...',
|
inst.use = use
|
||||||
|
inst.instructions = instructions
|
||||||
return inst
|
return inst
|
||||||
|
|
||||||
def asdict(self):
|
def asdict(self):
|
||||||
@@ -1003,14 +1003,16 @@ class material(facet):
|
|||||||
:return: Xmlschema compliant dictionary.
|
:return: Xmlschema compliant dictionary.
|
||||||
:rtype: dict
|
:rtype: dict
|
||||||
"""
|
"""
|
||||||
fac_dict = {
|
results = { "@location": self.location }
|
||||||
"value": parameter_asdict(self.value),
|
if self.value:
|
||||||
"@location": self.location,
|
results["value"] = parameter_asdict(self.value)
|
||||||
# TODO "instructions": "SAMPLE_INSTRUCTIONS",
|
if self.uri:
|
||||||
# TODO '@href': 'http://identifier.buildingsmart.org/uri/buildingsmart/ifc-4.3/prop/FireRating', #https://identifier.buildingsmart.org/uri/something
|
results["@uri"] = self.uri
|
||||||
# TODO '@use': 'optional'
|
if self.use:
|
||||||
}
|
results["@use"] = self.use
|
||||||
return fac_dict
|
if self.instructions:
|
||||||
|
results["@instructions"] = self.instructions
|
||||||
|
return results
|
||||||
|
|
||||||
def __call__(self, inst, logger):
|
def __call__(self, inst, logger):
|
||||||
"""Validate an ifc instance against that material facet.
|
"""Validate an ifc instance against that material facet.
|
||||||
|
|||||||
@@ -636,8 +636,12 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
ifc.createIfcProject()
|
ifc.createIfcProject()
|
||||||
# Milli prefix used to check measurement conversions
|
# Milli prefix used to check measurement conversions
|
||||||
lengthunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
|
lengthunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI")
|
||||||
areaunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="AREAUNIT", name="SQUARE_METRE", prefix="MILLI")
|
areaunit = ifcopenshell.api.run(
|
||||||
volumeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="VOLUMEUNIT", name="CUBIC_METRE", prefix="MILLI")
|
"unit.add_si_unit", ifc, unit_type="AREAUNIT", name="SQUARE_METRE", prefix="MILLI"
|
||||||
|
)
|
||||||
|
volumeunit = ifcopenshell.api.run(
|
||||||
|
"unit.add_si_unit", ifc, unit_type="VOLUMEUNIT", name="CUBIC_METRE", prefix="MILLI"
|
||||||
|
)
|
||||||
timeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="TIMEUNIT", name="SECOND")
|
timeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="TIMEUNIT", name="SECOND")
|
||||||
ifcopenshell.api.run("unit.assign_unit", ifc, units=[lengthunit, areaunit, volumeunit, timeunit])
|
ifcopenshell.api.run("unit.assign_unit", ifc, units=[lengthunit, areaunit, volumeunit, timeunit])
|
||||||
|
|
||||||
@@ -797,9 +801,17 @@ class TestIdsAuthoring(unittest.TestCase):
|
|||||||
assert bool(facet(wall_type)) is False
|
assert bool(facet(wall_type)) is False
|
||||||
|
|
||||||
def test_material_create(self):
|
def test_material_create(self):
|
||||||
m = ids.material.create(location="any", value="Test_Value")
|
facet = ids.material.create()
|
||||||
self.assertEqual(m.location, "any")
|
assert facet.asdict() == {"@location": "any"}
|
||||||
self.assertEqual(m.value, "Test_Value")
|
facet = ids.material.create(value="value", location="instance", uri="https://test.com", use="required", instructions="instructions")
|
||||||
|
assert facet.asdict() == {
|
||||||
|
"value": {"simpleValue": "value"},
|
||||||
|
"@location": "instance",
|
||||||
|
"@uri": "https://test.com",
|
||||||
|
"@use": "required",
|
||||||
|
"@instructions": "instructions",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
""" Creating IDS with restrictions """
|
""" Creating IDS with restrictions """
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user