Fix #3414. Only clear default scene, not custom scene when loading / creating IFCs.

This commit is contained in:
Dion Moult
2023-07-11 21:45:26 +10:00
parent 2a15743f8b
commit 4da7b355bf
3 changed files with 14 additions and 9 deletions
-4
View File
@@ -375,10 +375,6 @@ def load_post(scene):
else:
bpy.ops.workspace.append_activate(idname="BIM", filepath=os.path.join(cwd, "data", "workspace.blend"))
for obj in [bpy.data.objects.get("Camera"), bpy.data.objects.get("Light")]:
if obj:
bpy.data.objects.remove(obj)
# To improve usability for new users, we hijack the scene properties
# tab. We override default scene properties panels with our own poll
# to hide them unless the user has chosen to view Blender properties.
@@ -48,9 +48,6 @@ class NewProject(bpy.types.Operator):
def execute(self, context):
bpy.ops.wm.read_homefile()
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
if self.preset == "metric_m":
bpy.context.scene.BIMProjectProperties.export_schema = "IFC4"
bpy.context.scene.unit_settings.system = "METRIC"
@@ -104,6 +101,9 @@ class CreateProject(bpy.types.Operator):
props = context.scene.BIMProjectProperties
template = None if props.template_file == "0" else props.template_file
blenderbim.bim.schema.reload(props.export_schema)
if tool.Blender.is_default_scene():
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
core.create_project(tool.Ifc, tool.Project, schema=props.export_schema, template=template)
def rollback(self, data):
@@ -591,8 +591,9 @@ class LoadProject(bpy.types.Operator, IFCFileSelector):
if self.should_start_fresh_session:
bpy.ops.wm.read_homefile()
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
if tool.Blender.is_default_scene():
for obj in bpy.data.objects:
bpy.data.objects.remove(obj)
context.window_manager.fileselect_add(self)
return {"RUNNING_MODAL"}
@@ -57,6 +57,14 @@ class Blender:
area_index = screen_areas.index(current_area)
return context.screen.BIMAreaProperties[area_index].tab == tab
@classmethod
def is_default_scene(cls):
if len(bpy.context.scene.objects) != 3:
return False
if {obj.type for obj in bpy.context.scene.objects} == {"MESH", "LIGHT", "CAMERA"}:
return True
return False
@classmethod
def get_name(cls, ifc_class, name):
if not bpy.data.objects.get(f"{ifc_class}/{name}"):