New unassign aggregate feature.

This commit is contained in:
Dion Moult
2021-10-06 14:11:54 +11:00
parent 3aa36dd4b7
commit 9508858fcb
11 changed files with 115 additions and 7 deletions
@@ -23,6 +23,18 @@ Scenario: Assign object
And the variable "related_object" is "tool.Ifc.get().by_type('IfcBuildingStorey')[0].id()"
When I press "bim.assign_object(relating_object={relating_object}, related_object={related_object})"
Then the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
Then the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey"
Then the collection "IfcBuildingStorey/My Storey" is in the collection "IfcSite/My Site"
And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey"
And the collection "IfcBuildingStorey/My Storey" is in the collection "IfcSite/My Site"
Scenario: Unassign object
Given an empty IFC project
And the object "IfcBuildingStorey/My Storey" is selected
And I press "bim.enable_editing_aggregate"
And the variable "relating_object" is "tool.Ifc.get().by_type('IfcSite')[0].id()"
And the variable "related_object" is "tool.Ifc.get().by_type('IfcBuildingStorey')[0].id()"
And I press "bim.assign_object(relating_object={relating_object}, related_object={related_object})"
And the object "IfcBuildingStorey/My Storey" is selected
When I press "bim.unassign_object(relating_object={relating_object}, related_object={related_object})"
Then the object "IfcSite/My Site" is in the collection "IfcSite/My Site"
And the object "IfcBuildingStorey/My Storey" is in the collection "IfcBuildingStorey/My Storey"
And the collection "IfcBuildingStorey/My Storey" is in the collection "IfcProject/My Project"
@@ -29,3 +29,12 @@ class TestAssignObject:
subject.assign_object(ifc, aggregator, collector, relating_obj="relating_obj", related_obj="related_obj")
== "rel"
)
class TestUnassignObject:
def test_run(self, ifc, collector):
ifc.get_entity("related_obj").should_be_called().will_return("related_object")
ifc.run("aggregate.unassign_object", product="related_object").should_be_called().will_return("rel")
collector.assign("relating_obj").should_be_called()
collector.assign("related_obj").should_be_called()
assert subject.unassign_object(ifc, collector, relating_obj="relating_obj", related_obj="related_obj") == "rel"
@@ -99,3 +99,21 @@ class TestAssign(NewFile):
subject.assign(element_obj)
assert len(element_obj.users_collection) == 1
assert element_obj.users_collection[0].name == element_obj.name
def test_in_decomposition_mode_existing_collections_are_reassigned_to_the_correct_place_in_the_hierarchy(self):
bpy.ops.bim.create_project()
space_obj = bpy.data.objects.new("IfcSpace/Name", None)
space_element = tool.Ifc.get().createIfcSpace()
tool.Ifc.link(space_element, space_obj)
space_collection = bpy.data.collections.new("IfcSpace/Name")
bpy.context.scene.collection.children.link(space_collection)
space_collection.objects.link(space_obj)
ifcopenshell.api.run(
"aggregate.assign_object",
tool.Ifc.get(),
relating_object=tool.Ifc.get().by_type("IfcSite")[0],
product=space_element,
)
subject.assign(space_obj)
assert bpy.context.scene.collection.children.find(space_collection.name) == -1
assert bpy.data.collections.get("IfcSite/My Site").children.find(space_collection.name) != -1