mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
New feature to select all objects in same container
This commit is contained in:
@@ -53,3 +53,16 @@ Scenario: Select container
|
||||
And I press "bim.assign_container(structure={site})"
|
||||
When I press "bim.select_container"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Select similar container
|
||||
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"
|
||||
And the variable "site" is "tool.Ifc.get().by_type('IfcSite')[0].id()"
|
||||
And I press "bim.assign_container(structure={site})"
|
||||
When I press "bim.select_similar_container"
|
||||
Then nothing happens
|
||||
|
||||
@@ -103,3 +103,13 @@ class TestSelectContainer:
|
||||
ifc.get_object("container").should_be_called().will_return("container_obj")
|
||||
spatial.set_active_object("container_obj").should_be_called()
|
||||
subject.select_container(ifc, spatial, obj="obj")
|
||||
|
||||
|
||||
class TestSelectSimilarContainer:
|
||||
def test_run(self, ifc, spatial):
|
||||
ifc.get_entity("obj").should_be_called().will_return("element")
|
||||
spatial.get_container("element").should_be_called().will_return("container")
|
||||
spatial.get_decomposed_elements("container").should_be_called().will_return(["contained_element"])
|
||||
ifc.get_object("contained_element").should_be_called().will_return("contained_obj")
|
||||
spatial.select_object("contained_obj").should_be_called()
|
||||
subject.select_similar_container(ifc, spatial, obj="obj")
|
||||
|
||||
@@ -128,6 +128,15 @@ class TestGetContainer(NewFile):
|
||||
assert subject.get_container(wall) == site
|
||||
|
||||
|
||||
class TestGetDecomposedElements(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
site = ifc.createIfcSite()
|
||||
wall = ifc.createIfcWall()
|
||||
ifcopenshell.api.run("spatial.assign_container", ifc, product=wall, relating_structure=site)
|
||||
assert subject.get_decomposed_elements(site) == [wall]
|
||||
|
||||
|
||||
class TestGetObjectMatrix(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
@@ -192,6 +201,14 @@ class TestRunSpatialAssignContainer(NewFile):
|
||||
pass
|
||||
|
||||
|
||||
class TestSelectObject(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
bpy.context.scene.collection.objects.link(obj)
|
||||
subject.select_object(obj)
|
||||
assert obj in bpy.context.selected_objects
|
||||
|
||||
|
||||
class TestSetActiveObject(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
|
||||
Reference in New Issue
Block a user