Fix #2317 add graphical support for viewing and editing referenced structures

This commit is contained in:
Dion Moult
2022-08-22 13:52:12 +10:00
parent 0844d6f52e
commit 9821c3af67
9 changed files with 145 additions and 24 deletions
@@ -41,6 +41,31 @@ Scenario: Copy to container
And I press "bim.copy_to_container"
Then the object "IfcWall/Cube.001" is in the collection "IfcSite/My Site"
Scenario: Reference structure
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
And I press "bim.enable_editing_container"
When I set "scene.BIMSpatialProperties.containers[0].is_selected" to "True"
And I press "bim.reference_structure"
Then nothing happens
Scenario: Dereference structure
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
And I press "bim.assign_class"
And the object "IfcWall/Cube" is selected
And I press "bim.enable_editing_container"
When I set "scene.BIMSpatialProperties.containers[0].is_selected" to "True"
And I press "bim.reference_structure"
And I press "bim.dereference_structure"
Then nothing happens
Scenario: Select container
Given an empty IFC project
And I add a cube
+14
View File
@@ -20,6 +20,20 @@ import blenderbim.core.spatial as subject
from test.core.bootstrap import ifc, collector, spatial
class TestReferenceStructure:
def test_run(self, ifc, spatial):
spatial.can_reference("structure", "element").should_be_called().will_return(True)
ifc.run("spatial.reference_structure", product="element", relating_structure="structure").should_be_called()
subject.reference_structure(ifc, spatial, structure="structure", element="element")
class TestDereferenceStructure:
def test_run(self, ifc, spatial):
spatial.can_reference("structure", "element").should_be_called().will_return(True)
ifc.run("spatial.dereference_structure", product="element", relating_structure="structure").should_be_called()
subject.dereference_structure(ifc, spatial, structure="structure", element="element")
class TestAssignContainer:
def test_run(self, ifc, collector, spatial):
spatial.can_contain("structure_obj", "element_obj").should_be_called().will_return(True)
+19
View File
@@ -92,6 +92,25 @@ class TestCanContain(NewFile):
assert subject.can_contain(structure_obj, element_obj) is True
class TestCanReference(NewFile):
def test_an_element_can_reference_a_spatial_element(self):
ifc = ifcopenshell.file()
assert subject.can_reference(ifc.createIfcSite(), ifc.createIfcWall()) is True
def test_an_element_can_reference_a_spatial_element_ifc2x3(self):
ifc = ifcopenshell.file(schema="IFC2X3")
tool.Ifc.set(ifc)
assert subject.can_reference(ifc.createIfcSite(), ifc.createIfcWall()) is True
def test_a_non_spatial_element_cannot_reference_anything(self):
ifc = ifcopenshell.file()
assert subject.can_reference(ifc.createIfcWall(), ifc.createIfcWall()) is False
def test_a_non_element_cannot_reference_anything(self):
ifc = ifcopenshell.file()
assert subject.can_reference(ifc.createIfcSite(), ifc.createIfcTask()) is False
class TestDisableEditing(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)