Fix isolating drawing camera now that we have a new collection structure

This commit is contained in:
Dion Moult
2024-06-24 23:40:48 +10:00
parent 713e9c8e14
commit 44100f3c46
+23 -18
View File
@@ -1729,28 +1729,33 @@ class Drawing(blenderbim.core.tool.Drawing):
@classmethod @classmethod
def isolate_camera_collection(cls, camera: bpy.types.Object) -> None: def isolate_camera_collection(cls, camera: bpy.types.Object) -> None:
views_collection = bpy.data.collections.get("Views") drawings = [e for e in tool.Ifc.get().by_type("IfcAnnotation") if e.ObjectType == "DRAWING"]
for collection in views_collection.children: drawing_collections = []
# We assume the project collection is at the top level camera_collection = camera.BIMObjectProperties.collection
for project_collection in bpy.context.view_layer.layer_collection.children: for drawing in drawings:
# We assume a convention that the 'Views' collection is directly if not (drawing_obj := tool.Ifc.get_object(drawing)):
# in the project collection continue
if ( if not (drawing_collection := drawing_obj.BIMObjectProperties.collection):
"Views" in project_collection.children continue
and collection.name in project_collection.children["Views"].children if drawing_obj == camera:
): drawing_collection.hide_render = False
project_collection.children["Views"].children[collection.name].hide_viewport = True else:
bpy.data.collections.get(collection.name).hide_render = True drawing_collection.hide_render = True
project_collection.children["Views"].children[ project = tool.Ifc.get_object(tool.Ifc.get().by_type("IfcProject")[0])
camera.BIMObjectProperties.collection.name project_collection = project.BIMObjectProperties.collection
].hide_viewport = False for layer_collection in bpy.context.view_layer.layer_collection.children:
camera.BIMObjectProperties.collection.hide_render = False if layer_collection.collection == project_collection:
for layer_collection2 in layer_collection.children:
if layer_collection2.collection in drawing_collections:
layer_collection2.hide_viewport = True
elif layer_collection2.collection == camera_collection:
layer_collection2.hide_viewport = False
@classmethod @classmethod
def activate_drawing(cls, camera: bpy.types.Object) -> None: def activate_drawing(cls, camera: bpy.types.Object) -> None:
selected_objects_before = bpy.context.selected_objects selected_objects_before = bpy.context.selected_objects
# Sync viewport objects visibility with selectors from EPset_Drawing/Include and /Exclude # Sync viewport objects visibility with selectors from EPset_Drawing/Include and /Exclude
drawing = tool.Ifc.get_entity(camera) drawing = tool.Ifc.get_entity(camera)
@@ -1839,7 +1844,7 @@ class Drawing(blenderbim.core.tool.Drawing):
cls.import_camera_props(drawing, camera) cls.import_camera_props(drawing, camera)
for obj in selected_objects_before: for obj in selected_objects_before:
obj.hide_set(False) obj.hide_set(False)
obj.select_set(True) obj.select_set(True)
@classmethod @classmethod