mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
New projects now load with a Views and Types collection with appropriate visibility settings.
This commit is contained in:
@@ -1437,27 +1437,8 @@ class IfcImporter:
|
||||
self.create_spatial_decomposition_collection(self.project["blender"], orphaned_spaces)
|
||||
orphaned_spaces = [e for e in self.spatial_elements if e.GlobalId not in self.collections]
|
||||
|
||||
self.create_views_collection()
|
||||
self.create_type_collection()
|
||||
|
||||
def create_type_collection(self):
|
||||
for collection in self.project["blender"].children:
|
||||
if collection.name == "Types":
|
||||
self.type_collection = collection
|
||||
break
|
||||
if not self.type_collection:
|
||||
self.type_collection = bpy.data.collections.new("Types")
|
||||
self.project["blender"].children.link(self.type_collection)
|
||||
|
||||
def create_views_collection(self):
|
||||
view_collection = None
|
||||
for collection in self.project["blender"].children:
|
||||
if collection.name == "Views":
|
||||
view_collection = collection
|
||||
break
|
||||
if not view_collection:
|
||||
view_collection = bpy.data.collections.new("Views")
|
||||
self.project["blender"].children.link(view_collection)
|
||||
tool.Loader.create_project_collection("Views")
|
||||
self.type_collection = tool.Loader.create_project_collection("Types")
|
||||
|
||||
def create_spatial_decomposition_collection(self, parent, related_objects):
|
||||
for element in related_objects:
|
||||
|
||||
@@ -83,6 +83,7 @@ def create_project(ifc, project, schema=None, template=None):
|
||||
|
||||
project.set_context(body)
|
||||
project.set_active_spatial_element(storey)
|
||||
project.create_project_collections()
|
||||
|
||||
if template:
|
||||
project.append_all_types_from_template(template)
|
||||
|
||||
@@ -540,6 +540,7 @@ class Owner:
|
||||
class Project:
|
||||
def append_all_types_from_template(cls, template): pass
|
||||
def create_empty(cls, name): pass
|
||||
def create_project_collections(cls): pass
|
||||
def load_default_thumbnails(cls): pass
|
||||
def run_aggregate_assign_object(cls, relating_obj=None, related_obj=None): pass
|
||||
def run_context_add_context(cls, context_type=None, context_identifier=None, target_view=None, parent=None): pass
|
||||
|
||||
@@ -33,6 +33,21 @@ from pathlib import Path
|
||||
|
||||
|
||||
class Loader(blenderbim.core.tool.Loader):
|
||||
@classmethod
|
||||
def create_project_collection(self, name):
|
||||
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||
project_collection = project_obj.BIMObjectProperties.collection
|
||||
for collection in project_collection.children:
|
||||
if collection.name == name:
|
||||
return collection
|
||||
collection = bpy.data.collections.new(name)
|
||||
project_collection.children.link(collection)
|
||||
if name == "Types":
|
||||
project_layer = bpy.context.view_layer.layer_collection.children.get(project_collection.name)
|
||||
if project_layer:
|
||||
project_layer.children[collection.name].hide_viewport = True
|
||||
return collection
|
||||
|
||||
@classmethod
|
||||
def get_mesh_name(cls, geometry):
|
||||
representation_id = geometry.id
|
||||
|
||||
@@ -40,6 +40,11 @@ class Project(blenderbim.core.tool.Project):
|
||||
def create_empty(cls, name):
|
||||
return bpy.data.objects.new(name, None)
|
||||
|
||||
@classmethod
|
||||
def create_project_collections(cls):
|
||||
tool.Loader.create_project_collection("Views")
|
||||
tool.Loader.create_project_collection("Types")
|
||||
|
||||
@classmethod
|
||||
def load_default_thumbnails(cls):
|
||||
if tool.Ifc.get().by_type("IfcElementType"):
|
||||
|
||||
@@ -91,6 +91,7 @@ class TestCreateProject:
|
||||
|
||||
project.set_context("body").should_be_called()
|
||||
project.set_active_spatial_element("storey").should_be_called()
|
||||
project.create_project_collections().should_be_called()
|
||||
|
||||
project.load_default_thumbnails().should_be_called()
|
||||
project.set_default_context().should_be_called()
|
||||
@@ -122,6 +123,7 @@ class TestCreateProject:
|
||||
|
||||
project.set_context("body").should_be_called()
|
||||
project.set_active_spatial_element("storey").should_be_called()
|
||||
project.create_project_collections().should_be_called()
|
||||
|
||||
project.append_all_types_from_template("template").should_be_called()
|
||||
|
||||
@@ -162,6 +164,7 @@ class TestCreateProject:
|
||||
|
||||
project.set_context("body").should_be_called()
|
||||
project.set_active_spatial_element("storey").should_be_called()
|
||||
project.create_project_collections().should_be_called()
|
||||
|
||||
project.load_default_thumbnails().should_be_called()
|
||||
project.set_default_context().should_be_called()
|
||||
|
||||
Reference in New Issue
Block a user