How can I link a dupligroup of a group from File A in to File B and override the material of an object within the dupligroup with a material from File B?
The end goal would be to have multiple dupligroups of linked objects all linked from one file, but with different materials. Having the code in one script with the dupligroups and the materials to be applied would be ideal; like this:
I got the idea from this video on Python overrides in Blender: https://youtu.be/bOLMkw_wDGE
The video just shows how to override the attributes of materials and modifiers, but it seems like it should be possible to override a whole material of a dupligroup's child objects. For example:
- source.blend has a group calling 'thing' with an object called 'box' in it with a material applied called 'red'.
- dest.blend has a material called 'blue' and a dupligroup of 'thing' from source.blend.
- In dest.blend I want to override the 'red' material and put 'blue' on the 'box' that is within the linked dupligroup of 'thing.'
- The final goal is being able to import multiple dupligroups of 'thing' and have different materials (from dest.blend) on all of the different dupligroups' 'box' objects.
The closest I've come is this Python line within dest.blend in the python console:
bpy.data.objects['box'].material_slots['red'].material = bpy.data.materials['blue']
This does NOT give me an error message (and it does autocomplete to that point) but it just doesn't do anything.
This is the closest I've come because all my other attempts have given me error messages. It also looked like I was on the right track because just putting in:
which matches the syntax of:
But as I said it didn't seem to do anything.
What am I doing wrong here? Is it even possible to do this with a dupligroup? Any ideas would be very much appreciated. Thank you.
A few notes: I do know about the Edit Linked Libraries add-on, but that doesn't work for what I want to use this method for. As far as I can tell the add-on just lets you more easily edit the linked object's source file thereby editing the linked object, whereas with this method I'd like to be able to have multiple instances of the linked object all linked from one file, but with different materials.
I also know about this thread: Multiple Linked Objects with unique Materials / Group Materials override but not only can I not get any of those examples to work, but also they're just dealing with linked objects and not dupligroups. Dupligroups are a lot more useful in my opinion.
I am new to Blender Python scripting so specific code examples with explanations would be very much appreciated. Thank you.
(This question was asked about Blender versions 2.7*)
This is a (vastly improved) repeat of a question I asked on BlenderArtists.org: http://blenderartists.org/forum/showthread.php?385851-Override-dupligroup-s-object-s-material&highlight= I hope that's okay. The thread died months ago without any solutions.