Fix #2274. You can now purge unused types.

This commit is contained in:
Dion Moult
2023-02-13 15:20:56 +11:00
parent 7d979e5a04
commit 007d984baf
11 changed files with 109 additions and 9 deletions
@@ -1,6 +1,25 @@
@type
Feature: Type
Scenario: Add type - adding via manual class assignment
Given an empty IFC project
And I add a cube
And the object "Cube" is selected
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
When I press "bim.assign_class"
Then nothing happens
Scenario: Add type - add from empty template
Given an empty IFC project
And I press "bim.launch_type_manager"
And I set "scene.BIMModelProperties.type_class" to "IfcWallType"
And I set "scene.BIMModelProperties.type_predefined_type" to "SOLIDWALL"
And I set "scene.BIMModelProperties.type_template" to "EMPTY"
When I press "bim.add_type"
Then the object "IfcWallType/TYPEX" is an "IfcWallType"
And the object "IfcWallType/TYPEX" has no data
Scenario: Enable editing type
Given an empty IFC project
And I add a cube
@@ -171,3 +190,15 @@ Scenario: Select similar type
And I press "bim.select_similar_type"
Then the object "IfcWall/Cube" is selected
And the object "IfcWall/Cube.001" is selected
Scenario: Purge unused types
Given an empty IFC project
And I press "bim.launch_type_manager"
And I set "scene.BIMModelProperties.type_class" to "IfcWallType"
And I set "scene.BIMModelProperties.type_predefined_type" to "SOLIDWALL"
And I set "scene.BIMModelProperties.type_template" to "EMPTY"
When I press "bim.add_type"
Then the object "IfcWallType/TYPEX" is an "IfcWallType"
And the object "IfcWallType/TYPEX" has no data
When I press "bim.purge_unused_types"
Then the object "IfcWallType/TYPEX" does not exist
+1 -2
View File
@@ -124,6 +124,5 @@ class TestSelectSimilarContainer:
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()
spatial.select_products(["contained_element"]).should_be_called()
subject.select_similar_container(ifc, spatial, obj="obj")
+11
View File
@@ -39,3 +39,14 @@ class TestAssignType:
ifc.get_object("element").should_be_called().will_return("obj")
type.disable_editing("obj").should_be_called()
subject.assign_type(ifc, type, element="element", type="type")
class TestPurgeUnusedTypes:
def test_run(self, ifc, type):
type.get_model_types().should_be_called().will_return(["element_type"])
type.get_type_occurrences("element_type").should_be_called().will_return([])
ifc.run("root.remove_product", product="element_type").should_be_called()
ifc.get_object("element_type").should_be_called().will_return("obj")
ifc.unlink(obj="obj").should_be_called()
type.remove_object("obj").should_be_called()
subject.purge_unused_types(ifc, type)
+25
View File
@@ -114,6 +114,14 @@ class TestGetIfcRepresentationClass(NewFile):
assert subject.get_ifc_representation_class(ifc.createIfcColumn()) is None
class TestGetModelTypes(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
assert subject.get_model_types() == [wall_type]
class TestGetObjectData(NewFile):
def test_run(self):
data = bpy.data.meshes.new("Mesh")
@@ -139,6 +147,16 @@ class TestGetRepresentationContext(NewFile):
assert subject.get_representation_context(representation) == context
class TestGetTypeOccurrences(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
tool.Ifc.set(ifc)
wall_type = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWallType")
wall = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcWall")
ifcopenshell.api.run("type.assign_type", ifc, related_object=wall, relating_type=wall_type)
assert subject.get_type_occurrences(wall_type) == (wall,)
class TestHasMaterialUsage(NewFile):
def test_getting_a_profile_set_usage(self):
ifc = ifcopenshell.file()
@@ -149,6 +167,13 @@ class TestHasMaterialUsage(NewFile):
assert subject.has_material_usage(element) is True
class TestRemoveObject(NewFile):
def test_run(self):
obj = bpy.data.objects.new("Object", None)
subject.remove_object(obj)
assert not bpy.data.objects.get("Object")
class TestRunGeometryAddRepresentation(NewFile):
def test_nothing(self):
pass