Basic implementation to bulk convert relevant IFC classes to a Brick model

This commit is contained in:
Dion Moult
2022-01-10 17:30:49 +11:00
parent 666e484b2b
commit 7a6df49348
9 changed files with 99 additions and 1 deletions
@@ -96,3 +96,16 @@ Scenario: Add brick feed
And additionally the object "IfcAirTerminalBox/Cube" is selected
When I press "bim.add_brick_feed"
Then nothing happens
Scenario: Convert IFC to brick
Given an empty IFC project
And I press "bim.load_brick_project(filepath='{cwd}/test/files/spaces.ttl')"
And I press "bim.convert_brick_project"
And I set "scene.BIMBrickProperties.namespace" to "http://example.org/digitaltwin#"
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcUnitaryEquipment"
And I set "scene.BIMRootProperties.ifc_predefined_type" to "AIRHANDLER"
And I press "bim.assign_class"
When I press "bim.convert_ifc_to_brick"
Then nothing happens
+15
View File
@@ -136,3 +136,18 @@ class TestAddBrickFeed:
brick.get_brick("destination_element").should_be_called().will_return("destination_brick")
brick.add_feed("source_brick", "destination_brick").should_be_called()
subject.add_brick_feed(ifc, brick, source="source", destination="destination")
class TestConvertIfcToBrick:
def test_run(self, brick):
brick.get_convertable_brick_objects_and_elements().should_be_called().will_return([("obj", "element")])
brick.get_brick_class("element").should_be_called().will_return("brick_class")
brick.run_add_brick(
obj="obj", namespace="namespace", brick_class="brick_class", library="library"
).should_be_called()
subject.convert_ifc_to_brick(brick, namespace="namespace", library="library")
def test_not_converting_an_element_where_we_cannot_find_the_corresponding_brick_class(self, brick):
brick.get_convertable_brick_objects_and_elements().should_be_called().will_return([("obj", "element")])
brick.get_brick_class("element").should_be_called().will_return(None)
subject.convert_ifc_to_brick(brick, namespace="namespace", library="library")
+23
View File
@@ -186,6 +186,13 @@ class TestGetBrick(NewFile):
assert subject.get_brick(element) == "http://example.org/digitaltwin#globalid"
class TestGetBrickClass(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
element = ifc.createIfcAirTerminalBox()
assert subject.get_brick_class(element) == "https://brickschema.org/schema/Brick#TerminalUnit"
class TestGetBrickPath(NewFile):
def test_run(self):
TestLoadBrickFile().test_run()
@@ -208,6 +215,17 @@ class TestGetBrickifcProject(NewFile):
)
class TestGetConvertableBrickObjectsAndElements(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
element = ifc.createIfcAirTerminalBox()
obj = bpy.data.objects.new("Object", None)
tool.Ifc.link(element, obj)
ifc.createIfcWall()
assert subject.get_convertable_brick_objects_and_elements() == [(obj, element)]
class TestGetItemClass(NewFile):
def test_run(self):
TestLoadBrickFile().test_run()
@@ -286,6 +304,11 @@ class TestPopBrickBreadcrumb(NewFile):
assert bpy.context.scene.BIMBrickProperties.brick_breadcrumbs[0].name == "foo"
class TestRunAddBrick(NewFile):
def test_nothing(self):
pass
class TestRunAssignBrickReference(NewFile):
def test_nothing(self):
pass