here is a code that keeps a specific group of objects related to another object modifiers this is how it works :
- add the selected objects to a group named 'linked objects'
- rename the active object 'source object'
- whenever the function is called it copies the modifiers parameters from the 'source object' to the rest objects in the group and if the modifier is not present it creates a new one
- the function is appended to the
scene_update_pre()
handler to be called automatically
Note :
- before you run the script make sure to select your objects and the active object is going to be the source object thus it will be renamed ( you can make a dummy object as the source to keep the names)
- you can add/remove other objects later to/from the group because the update is related to the group not specific objects
import bpy
bpy.context.active_object.name = 'source_object'
linked_objects = bpy.data.groups.new('Linked_objects')
selected_objects = [obj for obj in bpy.context.selected_objects
if obj.type == bpy.context.active_object.type]
for obj in selected_objects:
linked_objects.objects.link(obj)
def link_modifiers(context):
linked_objects = bpy.data.groups['Linked_objects'].objects
source_object = bpy.context.scene.objects['source_object']
for obj in linked_objects:
for mSrc in source_object.modifiers:
mDst = obj.modifiers.get(mSrc.name, None)
if not mDst:
mDst = obj.modifiers.new(mSrc.name, mSrc.type)
# collect names of writeable properties
properties = [p.identifier for p in mSrc.bl_rna.properties
if not p.is_readonly]
# copy those properties
for prop in properties:
setattr(mDst, prop, getattr(mSrc, prop))
bpy.app.handlers.scene_update_pre.append(link_modifiers)
the code for copying the modifiers is from this answer by Adhi so thanks Adhi
the code needs more tweaking especially the handler choice I'm new to this so any advice would be appreciated
Animation Render test with two modifiers with drivers applied only to the source object "the orange cube":
render result