mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 08:16:51 +00:00
You can now unload a partially loaded project
This commit is contained in:
@@ -22,6 +22,7 @@ from . import ui, prop, operator
|
|||||||
classes = (
|
classes = (
|
||||||
operator.CreateProject,
|
operator.CreateProject,
|
||||||
operator.LoadProject,
|
operator.LoadProject,
|
||||||
|
operator.UnloadProject,
|
||||||
operator.LoadProjectElements,
|
operator.LoadProjectElements,
|
||||||
operator.SelectLibraryFile,
|
operator.SelectLibraryFile,
|
||||||
operator.ChangeLibraryElement,
|
operator.ChangeLibraryElement,
|
||||||
|
|||||||
@@ -524,6 +524,18 @@ class LoadProject(bpy.types.Operator):
|
|||||||
return {"RUNNING_MODAL"}
|
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):
|
class LoadProjectElements(bpy.types.Operator):
|
||||||
bl_idname = "bim.load_project_elements"
|
bl_idname = "bim.load_project_elements"
|
||||||
bl_label = "Load Project Elements"
|
bl_label = "Load Project Elements"
|
||||||
|
|||||||
@@ -56,8 +56,9 @@ class BIM_PT_project(Panel):
|
|||||||
pprops,
|
pprops,
|
||||||
"active_filter_category_index",
|
"active_filter_category_index",
|
||||||
)
|
)
|
||||||
row = self.layout.row()
|
row = self.layout.row(align=True)
|
||||||
row.operator("bim.load_project_elements")
|
row.operator("bim.load_project_elements")
|
||||||
|
row.operator("bim.unload_project", text="", icon="CANCEL")
|
||||||
|
|
||||||
def draw_project_ui(self, context):
|
def draw_project_ui(self, context):
|
||||||
props = context.scene.BIMProperties
|
props = context.scene.BIMProperties
|
||||||
|
|||||||
@@ -129,6 +129,12 @@ def an_ifc_file_exists():
|
|||||||
return ifc
|
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):
|
def the_object_name_does_not_exist(name):
|
||||||
assert bpy.data.objects.get(name) is None, "Object exists"
|
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 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,
|
'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 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 "(.*)" 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 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,
|
'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 "IfcBuildingStorey/Level 1" does not exist
|
||||||
And the object "IfcWall/Wall" 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"
|
||||||
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user