1
$\begingroup$

The issue was happened when I try defining which collection is linked and which one is library override. When trying to target the linked collection, it is always pointing into the library override one, as you can see on the image below there are two collections named "chr_Small". The problem is when I try to do

bpy.data.collections['chr_Small'].override_hierarchy_create(scene, view_layer, do_fully_editable=True)

enter image description here

I can not do it more than one, however if I do for loop to get the actual collection as below code, I can do another override_hierarchy_create()

bpy.data.collections[-1].override_hierarchy_create(scene, view_layer, do_fully_editable=True)

enter image description here

However I need to do for quite many times on the same collection within the same library file, and also adding another library file.

Is there any proper/easy way to target the actual linked collection instead of relying on the index number of collection list in the scene ?

$\endgroup$

1 Answer 1

1
$\begingroup$

I realize there is .name_full attribute that I found on Data API which can be used to filter the linked one, my code is having if statement for comparing the full name. I tried to check using .override_library and .original , but it doesn't help

for col in bpy.data.collections:
    
    blend_name = "file.blend"
    col_full_name = col.name + " " + blend_name 
    
    
    if col.name_full == col_full_name:
        
        new_override_col = col.override_hierarchy_create(scene, view_layer, do_fully_editable=True)

enter image description here

For now I can use this as a solution, but feel free to post an anser if there is any better way. Thanks!

$\endgroup$
1
  • $\begingroup$ col.library should work $\endgroup$
    – X Y
    Commented Jul 13, 2023 at 15:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .