mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 21:50:01 +00:00
Fix Bonsai classification tests after bonsai bsdd changes (#6988)
This commit is contained in:
@@ -473,3 +473,11 @@ class Bsdd(bonsai.core.tool.Bsdd):
|
|||||||
data: Bsdd.BSDDJsonData = json.loads(ref.Name)
|
data: Bsdd.BSDDJsonData = json.loads(ref.Name)
|
||||||
results.append((ref.Location, data["name"], data["description"]))
|
results.append((ref.Location, data["name"], data["description"]))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_library_active(cls, uri: str, state: bool):
|
||||||
|
for dictionary in cls.get_bsdd_props().dictionaries:
|
||||||
|
if dictionary.uri == uri:
|
||||||
|
dictionary.is_active = state
|
||||||
|
return
|
||||||
|
raise ValueError(f"URI '{uri}' could not be found in dictionaries!")
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ class TestAddClassificationReferenceFromBSDD(NewFile):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
assert element
|
assert element
|
||||||
|
|
||||||
bpy.ops.bim.load_bsdd_domains()
|
bpy.ops.bim.load_bsdd_dictionaries()
|
||||||
uri = "https://identifier.buildingsmart.org/uri/molio/cciconstruction/1.0"
|
uri = "https://identifier.buildingsmart.org/uri/molio/cciconstruction/1.0"
|
||||||
bpy.ops.bim.set_active_bsdd_domain(name="CCI Construction", uri=uri)
|
tool.Bsdd.set_library_active(uri, True)
|
||||||
props = tool.Bsdd.get_bsdd_props()
|
props = tool.Bsdd.get_bsdd_props()
|
||||||
tool.Classification.get_classification_props().classification_source = "BSDD"
|
tool.Classification.get_classification_props().classification_source = "BSDD"
|
||||||
props.should_filter_ifc_class = True
|
props.should_filter_ifc_class = True
|
||||||
@@ -67,9 +67,9 @@ class TestAddClassificationReferenceFromBSDD(NewFile):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
assert element
|
assert element
|
||||||
|
|
||||||
bpy.ops.bim.load_bsdd_domains()
|
bpy.ops.bim.load_bsdd_dictionaries()
|
||||||
uri = "https://identifier.buildingsmart.org/uri/molio/cciconstruction/1.0"
|
uri = "https://identifier.buildingsmart.org/uri/molio/cciconstruction/1.0"
|
||||||
bpy.ops.bim.set_active_bsdd_domain(name="CCI Construction", uri=uri)
|
tool.Bsdd.set_library_active(uri, True)
|
||||||
props = tool.Bsdd.get_bsdd_props()
|
props = tool.Bsdd.get_bsdd_props()
|
||||||
tool.Classification.get_classification_props().classification_source = "BSDD"
|
tool.Classification.get_classification_props().classification_source = "BSDD"
|
||||||
props.should_filter_ifc_class = True
|
props.should_filter_ifc_class = True
|
||||||
@@ -77,25 +77,33 @@ class TestAddClassificationReferenceFromBSDD(NewFile):
|
|||||||
bpy.ops.bim.search_bsdd_classifications()
|
bpy.ops.bim.search_bsdd_classifications()
|
||||||
# https://identifier.buildingsmart.org/uri/molio/cciconstruction/1.0/class/A-AAA
|
# https://identifier.buildingsmart.org/uri/molio/cciconstruction/1.0/class/A-AAA
|
||||||
props.active_classification_index = next(i for i, c in enumerate(props.classifications) if c.name == "Room")
|
props.active_classification_index = next(i for i, c in enumerate(props.classifications) if c.name == "Room")
|
||||||
bpy.ops.bim.get_bsdd_classification_properties()
|
tool.Pset.get_pset_props(obj="IfcSpace/Cube", obj_type="Object").pset_name = uri
|
||||||
psets = props.classification_psets
|
|
||||||
assert len(psets) == 1
|
|
||||||
pset = psets[0]
|
|
||||||
assert pset.name == "Pset_SpaceCommon"
|
|
||||||
assert len(pset.properties) == 1
|
|
||||||
pset_prop = pset.properties[0]
|
|
||||||
assert pset_prop.name == "Handicap Accessible"
|
|
||||||
pset_prop.bool_value = True
|
|
||||||
|
|
||||||
bpy.ops.bim.add_classification_reference_from_bsdd(obj="IfcSpace/Cube", obj_type="Object")
|
bpy.ops.bim.add_classification_reference_from_bsdd(obj="IfcSpace/Cube", obj_type="Object")
|
||||||
|
bpy.ops.bim.import_bsdd_classes(obj="IfcSpace/Cube", obj_type="Object")
|
||||||
|
props.active_class_index = 0
|
||||||
|
assert len(props.properties) == 1
|
||||||
|
bsdd_property = props.properties[0]
|
||||||
|
assert bsdd_property.pset == "Pset_SpaceCommon"
|
||||||
|
assert bsdd_property.name == "Handicap Accessible"
|
||||||
|
bsdd_property.is_selected = True
|
||||||
|
bpy.ops.bim.add_bsdd_properties(obj="IfcSpace/Cube", obj_type="Object")
|
||||||
pset = ifcopenshell.util.element.get_pset(element, "Pset_SpaceCommon")
|
pset = ifcopenshell.util.element.get_pset(element, "Pset_SpaceCommon")
|
||||||
assert pset and pset["Handicap Accessible"] == True
|
assert pset and pset["HandicapAccessible"] == False
|
||||||
refs = ifcopenshell.util.classification.get_references(element)
|
refs = ifcopenshell.util.classification.get_references(element)
|
||||||
assert len(refs) == 1
|
assert len(refs) == 1
|
||||||
assert next(iter(refs)).Location.startswith(uri)
|
assert next(iter(refs)).Location.startswith(uri)
|
||||||
|
|
||||||
def test_add_clasification_reference_with_object_type(self):
|
def test_add_clasification_reference_with_object_type(self):
|
||||||
|
"""
|
||||||
|
Check that an IfcSpace cube can be selected and receive a BSDD classification reference/property set
|
||||||
|
even if its IFC class mismatches the class bSDD expects by disabling class filtering.
|
||||||
|
Sets up the IFC4X3_ADD2 project, creates the cube, assigns IfcSpace, loads and activates the BSDD library,
|
||||||
|
searches for "check-in conveyor", adds the classification reference with obj_type="Object", and imports it.
|
||||||
|
Asserts 20 properties were loaded and that the first is in "ISet_AirportDomain", named "Conveying speed", and selected.
|
||||||
|
"""
|
||||||
|
tool.Project.get_project_props().export_schema = "IFC4X3_ADD2"
|
||||||
bpy.ops.bim.create_project()
|
bpy.ops.bim.create_project()
|
||||||
|
ifc_file = tool.Ifc.get()
|
||||||
context = bpy.context
|
context = bpy.context
|
||||||
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 4))
|
bpy.ops.mesh.primitive_cube_add(size=10, location=(0, 0, 4))
|
||||||
obj = bpy.data.objects["Cube"]
|
obj = bpy.data.objects["Cube"]
|
||||||
@@ -103,29 +111,27 @@ class TestAddClassificationReferenceFromBSDD(NewFile):
|
|||||||
element = tool.Ifc.get_entity(obj)
|
element = tool.Ifc.get_entity(obj)
|
||||||
assert element
|
assert element
|
||||||
|
|
||||||
|
bpy.ops.bim.load_bsdd_dictionaries()
|
||||||
|
uri = "https://identifier.buildingsmart.org/uri/bs-airport/airport/1.0"
|
||||||
|
tool.Bsdd.set_library_active(uri, True)
|
||||||
props = tool.Bsdd.get_bsdd_props()
|
props = tool.Bsdd.get_bsdd_props()
|
||||||
props.load_preview_domains = True
|
|
||||||
bpy.ops.bim.load_bsdd_domains()
|
|
||||||
uri = "https://identifier.buildingsmart.org/uri/ifcairport/ifcairport/0.9"
|
|
||||||
bpy.ops.bim.set_active_bsdd_domain(name="IFC Airport", uri=uri)
|
|
||||||
tool.Classification.get_classification_props().classification_source = "BSDD"
|
tool.Classification.get_classification_props().classification_source = "BSDD"
|
||||||
props.should_filter_ifc_class = False # Important due to class mismatch.
|
props.should_filter_ifc_class = False # Important due to class mismatch.
|
||||||
props.keyword = "check-in conveyor"
|
props.keyword = "check-in conveyor"
|
||||||
bpy.ops.bim.search_bsdd_classifications()
|
bpy.ops.bim.search_bsdd_classifications()
|
||||||
# https://identifier.buildingsmart.org/uri/bs-airport/airport/0.9/class/AD-BHS-006
|
# https://identifier.buildingsmart.org/uri/bs-airport/airport/1.0/class/AD-BHS-007
|
||||||
|
|
||||||
props.active_classification_index = next(
|
props.active_classification_index = next(
|
||||||
i for i, c in enumerate(props.classifications) if c.name == "Check-in conveyor"
|
i for i, c in enumerate(props.classifications) if c.name.lower() == "check-in conveyor"
|
||||||
)
|
)
|
||||||
bpy.ops.bim.get_bsdd_classification_properties()
|
|
||||||
psets = props.classification_psets
|
|
||||||
assert len(psets) == 1
|
|
||||||
pset = psets[0]
|
|
||||||
assert pset.name == "ISet_AirportDomain"
|
|
||||||
assert len(pset.properties) == 20
|
|
||||||
pset_prop = pset.properties[0]
|
|
||||||
assert pset_prop.name == "Conveying speed"
|
|
||||||
|
|
||||||
bpy.ops.bim.add_classification_reference_from_bsdd(obj="IfcSpace/Cube", obj_type="Object")
|
bpy.ops.bim.add_classification_reference_from_bsdd(obj="IfcSpace/Cube", obj_type="Object")
|
||||||
# Check this?
|
tool.Pset.get_pset_props(obj="IfcSpace/Cube", obj_type="Object").pset_name = uri
|
||||||
# assert element.ObjectType == "CHECKINCONVEYOR"
|
bpy.ops.bim.import_bsdd_classes(obj="IfcSpace/Cube", obj_type="Object")
|
||||||
|
|
||||||
|
props.active_class_index = 0
|
||||||
|
assert len(props.properties) == 20
|
||||||
|
bsdd_property = props.properties[0]
|
||||||
|
assert bsdd_property.pset == "ISet_AirportDomain"
|
||||||
|
assert bsdd_property.name == "Conveying speed"
|
||||||
assert not ifcopenshell.util.element.get_psets(element)
|
assert not ifcopenshell.util.element.get_psets(element)
|
||||||
|
|||||||
Reference in New Issue
Block a user