mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-11 10:06:47 +00:00
Fix #5256. Use layer collection visibility, not collection visibility to hide types.
This commit is contained in:
@@ -1137,11 +1137,7 @@ class IfcImporter:
|
||||
except:
|
||||
# Occurs when reloading a project
|
||||
pass
|
||||
project_collection = bpy.context.view_layer.layer_collection.children[self.project["blender"].name]
|
||||
if types_collection := project_collection.children.get("IfcTypeProduct"):
|
||||
types_collection.hide_viewport = False
|
||||
for obj in types_collection.collection.objects: # turn off all objects inside Types collection.
|
||||
obj.hide_set(True)
|
||||
tool.Collector.reset_default_visibility()
|
||||
|
||||
def clean_mesh(self):
|
||||
obj = None
|
||||
@@ -1155,19 +1151,11 @@ class IfcImporter:
|
||||
if not last_obj:
|
||||
return
|
||||
|
||||
# Temporarily unhide types collection to make sure all objects will be cleaned
|
||||
project_collection = bpy.context.view_layer.layer_collection.children[self.project["blender"].name]
|
||||
if types_collection := project_collection.children.get("IfcTypeProduct"):
|
||||
types_collection.hide_viewport = False
|
||||
bpy.context.view_layer.objects.active = last_obj
|
||||
|
||||
bpy.ops.object.editmode_toggle()
|
||||
bpy.ops.mesh.tris_convert_to_quads()
|
||||
bpy.ops.mesh.normals_make_consistent()
|
||||
bpy.ops.object.editmode_toggle()
|
||||
|
||||
if types_collection:
|
||||
types_collection.hide_viewport = True
|
||||
bpy.context.view_layer.objects.active = last_obj
|
||||
IfcStore.edited_objs.clear()
|
||||
|
||||
|
||||
@@ -59,11 +59,9 @@ class Collector(bonsai.core.tool.Collector):
|
||||
cls.link_to_collection_safe(obj, collection)
|
||||
elif element.is_a("IfcLinearPositioningElement"):
|
||||
collection = cls._create_project_child_collection("IfcLinearPositioningElement")
|
||||
collection.hide_viewport = False
|
||||
cls.link_to_collection_safe(obj, collection)
|
||||
elif element.is_a("IfcReferent"):
|
||||
collection = cls._create_project_child_collection("IfcReferent")
|
||||
collection.hide_viewport = False
|
||||
cls.link_to_collection_safe(obj, collection)
|
||||
elif tool.Ifc.get_schema() == "IFC2X3" and element.is_a("IfcSpatialStructureElement"):
|
||||
if collection := cls._create_own_collection(obj):
|
||||
@@ -94,7 +92,6 @@ class Collector(bonsai.core.tool.Collector):
|
||||
cls.link_to_collection_safe(obj, collection)
|
||||
else:
|
||||
collection = cls._create_project_child_collection("Unsorted")
|
||||
collection.hide_viewport = False
|
||||
cls.link_to_collection_safe(obj, collection)
|
||||
|
||||
@classmethod
|
||||
@@ -105,7 +102,8 @@ class Collector(bonsai.core.tool.Collector):
|
||||
collection = bpy.data.collections.new(name)
|
||||
project_obj = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||
project_obj.BIMObjectProperties.collection.children.link(collection)
|
||||
collection.hide_viewport = True
|
||||
if layer_collection := tool.Blender.get_layer_collection(collection):
|
||||
layer_collection.hide_viewport = True
|
||||
return collection
|
||||
|
||||
@classmethod
|
||||
@@ -148,3 +146,23 @@ class Collector(bonsai.core.tool.Collector):
|
||||
if collection.children.find(obj_or_col.name) != -1:
|
||||
return
|
||||
collection.children.link(obj_or_col)
|
||||
|
||||
@classmethod
|
||||
def reset_default_visibility(cls):
|
||||
project = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
|
||||
project_collection = project.BIMObjectProperties.collection
|
||||
for layer_collection in bpy.context.view_layer.layer_collection.children:
|
||||
if layer_collection.collection == project_collection:
|
||||
for layer_collection2 in layer_collection.children:
|
||||
name = layer_collection2.collection.name
|
||||
if name in (
|
||||
"IfcTypeProduct",
|
||||
"IfcOpeningElement",
|
||||
"IfcStructuralItem",
|
||||
"Unsorted",
|
||||
):
|
||||
layer_collection2.hide_viewport = True
|
||||
elif name.startswith("IfcAnnotation"):
|
||||
layer_collection2.hide_viewport = True
|
||||
else:
|
||||
layer_collection2.hide_viewport = False
|
||||
|
||||
@@ -60,21 +60,6 @@ class Loader(bonsai.core.tool.Loader):
|
||||
def set_settings(cls, settings: bonsai.bim.import_ifc.IfcImportSettings) -> None:
|
||||
cls.settings = settings
|
||||
|
||||
@classmethod
|
||||
def create_project_collection(cls, name: str) -> bpy.types.Collection:
|
||||
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_from_shape(cls, geometry: ifcopenshell.geom.ShapeType) -> str:
|
||||
representation_id = geometry.id
|
||||
|
||||
@@ -130,10 +130,11 @@ def main(
|
||||
if settings.drawing_guid:
|
||||
found_guid = False
|
||||
for f in files:
|
||||
try:
|
||||
try:
|
||||
f.by_guid(settings.drawing_guid)
|
||||
found_guid = True
|
||||
except: pass
|
||||
except:
|
||||
pass
|
||||
if not found_guid:
|
||||
raise ValueError(f"Unable to find guid {settings.drawing_guid!r}")
|
||||
sr.setElevationRefGuid(settings.drawing_guid)
|
||||
|
||||
Reference in New Issue
Block a user