I'm trying to do a library override on a material linked from an external blend file.
It can be done manually through the outliner by right clicking on the material -> Library Override / Make / Selected
How to do this by script ?
I tried this :
myLinkedMaterial.override_hierarchy_create(bpy.context.scene,bpy.context.view_layer,do_fully_editable = True)
but it does nothing... override_create() doesn't work either...
I also have this piece of code which is working on the override part, but only if the material has been manually selected in the outliner :
import bpy
def get_outliner_area():
if bpy.context.area.type!='OUTLINER':
for w in bpy.context.window_manager.windows:
s = w.screen
for a in s.areas:
if a.type == "OUTLINER":
return a
area = get_outliner_area()
region = next(region for region in area.regions if region.type == "WINDOW")
with bpy.context.temp_override(area=area, region=region):
for item in bpy.context.selected_ids:
if isinstance(item , bpy.types.Material):
bpy.ops.outliner.liboverride_operation()
I'm looking for a way to do this override on any linked material, without the need of selecting it manually beforehand in the outliner. Is it possible ?
A workaround would be to iterate on all the items listed in the outliner, but I can't find any clue on how to get access to this list... It seems that only the list of selected items are available, through bpy.context.selected_ids :(