0
$\begingroup$

Some context: I have a custom addon that renders additional passes like a height gradient for example: the addon modifies the object's material and when the render is finished, restores the original material state. Since I work with a lot of hipoly objects inside instanced collections, recently I experimented with linking the collections instead of copy-pasting them to shrink the file sizes. However this broke my rendering workflow as instanced collections have linked materials on that that I can't modify.

So my question: is there a way to remove/replace/modify materials on the linked objects in collections?

My first idea was to figure out if I can add break links or override materials. On linked objects in UI there's this button

enter image description here

However clicking on it doesn't do anything and shift-clicking produces an error:

The type of data-block MAinstanced_material_ob_object is not yet implemented
The data-block MAinstanced_material_ob_object could not be overridden

Second idea was switching link material from data to object.

for ob in bpy.data.objects:
    if ob.data.library:
        for slot in ob.material_slots:
            slot.link = 'OBJECT'
            slot.material = bpy.data.materials["mat1"]

This works on imported single objects but doesn't on objects inside instanced collections, I'm getting an error:

bpy_struct: attribute "material" from "MaterialSlot" is read-only

And then I tried to make a library override on the linked material from the Blender File Outliner section:

enter image description here

And this resulted in... duplication of my instanced collection and everything basically became broken. I'm not even sure if it's possible now. But any ideas are welcome. I'm uploading two blend files: one is the library file with the original collection and an object and the other one (render_file.blend) is the file with imported collection and objects : https://www.dropbox.com/scl/fi/g44427udeabow94myi403/instanced_materials.zip?rlkey=5csstvzcroe7abmxx5l2bv9qx&dl=1

$\endgroup$

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.