2
$\begingroup$

I like to create some automation in Python on a library override of a linked collection in Blender 3.4.1. I fail to make object P2 editable using Python (see image below). The operator that does the right job in the GUI is: bpy.ops.object.make_override_library. I used that on object P1, hence its override icon is no longer grayed out.

Objective is to make P2 editable using Python

I prefer to use an lower level API instead of an operator but cannot find it. If the operator is the only option, I am not sure how to set the right context. The below code is not working correctly since it is creating some objects outside the collection.

with bpy.context.temp_override(active_object=bpy.data.objects["P2"]):
    bpy.ops.object.make_override_library()
$\endgroup$

1 Answer 1

1
$\begingroup$

I ran into this same issue. This code has been working for me. It creates a library override on a collection without using your aforementioned operator.

col = bpy.data.collections[collection_name]
col.override_hierarchy_create(bpy.context.scene, bpy.context.view_layer, do_fully_editable = True)

Hope this helps!

Link to the docs

$\endgroup$
3
  • $\begingroup$ Unfortunately this will make everything editable which is not what I prefer but so far the best solution. $\endgroup$
    – Jiske
    Commented Apr 4, 2023 at 18:30
  • $\begingroup$ @Jiske you can set do_fully_editable to False $\endgroup$ Commented Apr 4, 2023 at 20:46
  • $\begingroup$ Hi Grant, I know that this is possible, but then I am back to my original problem of this post. What I did not mention in the original post is that the objects P1 an P2 have child objects which I prefer to keep non-editable. $\endgroup$
    – Jiske
    Commented Apr 6, 2023 at 18:07

You must log in to answer this question.

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