mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-07 12:56:26 +00:00
You can now add feed relationships in a Brick model from IFC elements
This commit is contained in:
@@ -74,3 +74,25 @@ Scenario: Add brick - with a brick IFC library
|
||||
And I set "scene.BIMBrickProperties.namespace" to "http://example.org/digitaltwin#"
|
||||
When I press "bim.add_brick"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add brick feed
|
||||
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"
|
||||
And I press "bim.add_brick"
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcAirTerminalBox"
|
||||
And I set "scene.BIMRootProperties.ifc_predefined_type" to "VARIABLEFLOWPRESSUREDEPENDANT"
|
||||
And I press "bim.assign_class"
|
||||
And I press "bim.add_brick"
|
||||
And the object "IfcUnitaryEquipment/Cube" is selected
|
||||
And additionally the object "IfcAirTerminalBox/Cube" is selected
|
||||
When I press "bim.add_brick_feed"
|
||||
Then nothing happens
|
||||
|
||||
@@ -126,3 +126,13 @@ class TestAddBrick:
|
||||
brick.add_brick("product", "namespace", "brick_class").should_be_called().will_return("brick_uri")
|
||||
brick.run_assign_brick_reference(obj="obj", library="library", brick_uri="brick_uri").should_be_called()
|
||||
subject.add_brick(ifc, brick, obj="obj", namespace="namespace", brick_class="brick_class", library="library")
|
||||
|
||||
|
||||
class TestAddBrickFeed:
|
||||
def test_run(self, ifc, brick):
|
||||
ifc.get_entity("source").should_be_called().will_return("source_element")
|
||||
ifc.get_entity("destination").should_be_called().will_return("destination_element")
|
||||
brick.get_brick("source_element").should_be_called().will_return("source_brick")
|
||||
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")
|
||||
|
||||
@@ -121,6 +121,21 @@ class TestAddBrickifcReference(NewFile):
|
||||
)
|
||||
|
||||
|
||||
class TestAddFeed(NewFile):
|
||||
def test_run(self):
|
||||
BrickStore.graph = brickschema.Graph()
|
||||
subject.add_feed("http://example.org/digitaltwin#source", "http://example.org/digitaltwin#destination")
|
||||
assert list(
|
||||
BrickStore.graph.triples(
|
||||
(
|
||||
URIRef("http://example.org/digitaltwin#source"),
|
||||
URIRef("https://brickschema.org/schema/Brick#feeds"),
|
||||
URIRef("http://example.org/digitaltwin#destination"),
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class TestClearBrickBrowser(NewFile):
|
||||
def test_run(self):
|
||||
bpy.context.scene.BIMBrickProperties.bricks.add()
|
||||
@@ -141,11 +156,34 @@ class TestClearProject(NewFile):
|
||||
|
||||
class TestExportBrickAttributes(NewFile):
|
||||
def test_run(self):
|
||||
assert subject.export_brick_attributes("http://example.org/digitaltwin#floor") == {"Identification": "http://example.org/digitaltwin#floor", "Name": "floor"}
|
||||
assert subject.export_brick_attributes("http://example.org/digitaltwin#floor") == {
|
||||
"Identification": "http://example.org/digitaltwin#floor",
|
||||
"Name": "floor",
|
||||
}
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
tool.Ifc.set(ifcopenshell.file(schema="IFC2X3"))
|
||||
assert subject.export_brick_attributes("http://example.org/digitaltwin#floor") == {"ItemReference": "http://example.org/digitaltwin#floor", "Name": "floor"}
|
||||
assert subject.export_brick_attributes("http://example.org/digitaltwin#floor") == {
|
||||
"ItemReference": "http://example.org/digitaltwin#floor",
|
||||
"Name": "floor",
|
||||
}
|
||||
|
||||
|
||||
class TestGetBrick(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
element = ifc.createIfcChiller()
|
||||
library = ifc.createIfcLibraryReference(Identification="http://example.org/digitaltwin#globalid")
|
||||
ifc.createIfcRelAssociatesLibrary(RelatedObjects=[element], RelatingLibrary=library)
|
||||
assert subject.get_brick(element) == "http://example.org/digitaltwin#globalid"
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
ifc = ifcopenshell.file(schema="IFC2X3")
|
||||
tool.Ifc.set(ifc)
|
||||
element = ifc.createIfcEnergyConversionDevice()
|
||||
library = ifc.createIfcLibraryReference(ItemReference="http://example.org/digitaltwin#globalid")
|
||||
ifc.createIfcRelAssociatesLibrary(RelatedObjects=[element], RelatingLibrary=library)
|
||||
assert subject.get_brick(element) == "http://example.org/digitaltwin#globalid"
|
||||
|
||||
|
||||
class TestGetBrickPath(NewFile):
|
||||
@@ -180,7 +218,9 @@ class TestGetLibraryBrickReference(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
library = ifc.createIfcLibraryInformation()
|
||||
reference = ifc.createIfcLibraryReference(Identification="http://example.org/digitaltwin#floor", ReferencedLibrary=library)
|
||||
reference = ifc.createIfcLibraryReference(
|
||||
Identification="http://example.org/digitaltwin#floor", ReferencedLibrary=library
|
||||
)
|
||||
assert subject.get_library_brick_reference(library, "http://example.org/digitaltwin#floor") == reference
|
||||
|
||||
def test_run_ifc2x3(self):
|
||||
|
||||
Reference in New Issue
Block a user