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
+21 -16
View File
@@ -1729,23 +1729,28 @@ 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: