You can now unload a partially loaded project

This commit is contained in:
Dion Moult
2021-09-12 15:42:59 +10:00
parent a9f76fc8c0
commit 5f29379a6d
5 changed files with 32 additions and 1 deletions
@@ -22,6 +22,7 @@ from . import ui, prop, operator
classes = (
operator.CreateProject,
operator.LoadProject,
operator.UnloadProject,
operator.LoadProjectElements,
operator.SelectLibraryFile,
operator.ChangeLibraryElement,
@@ -524,6 +524,18 @@ class LoadProject(bpy.types.Operator):
return {"RUNNING_MODAL"}
class UnloadProject(bpy.types.Operator):
bl_idname = "bim.unload_project"
bl_label = "Unload Project"
bl_options = {"REGISTER", "UNDO"}
def execute(self, context):
IfcStore.purge()
context.scene.BIMProperties.ifc_file = ""
context.scene.BIMProjectProperties.is_loading = False
return {"FINISHED"}
class LoadProjectElements(bpy.types.Operator):
bl_idname = "bim.load_project_elements"
bl_label = "Load Project Elements"
@@ -56,8 +56,9 @@ class BIM_PT_project(Panel):
pprops,
"active_filter_category_index",
)
row = self.layout.row()
row = self.layout.row(align=True)
row.operator("bim.load_project_elements")
row.operator("bim.unload_project", text="", icon="CANCEL")
def draw_project_ui(self, context):
props = context.scene.BIMProperties
+7
View File
@@ -129,6 +129,12 @@ def an_ifc_file_exists():
return ifc
def an_ifc_file_does_not_exist():
ifc = IfcStore.get_file()
if ifc:
assert False, "An IFC is available"
def the_object_name_does_not_exist(name):
assert bpy.data.objects.get(name) is None, "Object exists"
@@ -255,6 +261,7 @@ definitions = {
'the object "(.*)" is in the collection "(.*)"': the_object_name_is_in_the_collection_collection,
'the collection "(.*)" is in the collection "(.*)"': the_collection_name1_is_in_the_collection_name2,
"an IFC file exists": an_ifc_file_exists,
"an IFC file does not exist": an_ifc_file_does_not_exist,
'the object "(.*)" has a "(.*)" representation of "(.*)"': the_object_name_has_a_type_representation_of_context,
'the object "(.*)" is placed in the collection "(.*)"': the_object_name_is_placed_in_the_collection_collection,
'the object "(.*)" is contained in "(.*)"': the_object_name_is_contained_in_container_name,
@@ -94,3 +94,13 @@ class TestLoadProjectElements(test.bim.bootstrap.NewFile):
And the object "IfcBuildingStorey/Level 1" does not exist
And the object "IfcWall/Wall" does not exist
"""
class TestUnloadProject(test.bim.bootstrap.NewFile):
@test.bim.bootstrap.scenario
def test_unloading_a_project(self):
return """
When I press "bim.load_project(filepath='{cwd}/test/files/basic.ifc')"
And I press "bim.unload_project"
Then an IFC file does not exist
And "scene.BIMProjectProperties.is_loading" is "False"
"""