Skip to content

Instantly share code, notes, and snippets.

@kuguma
Created June 18, 2021 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuguma/f37a7aa541c08f9bd515a0f3ddf507d7 to your computer and use it in GitHub Desktop.
Save kuguma/f37a7aa541c08f9bd515a0f3ddf507d7 to your computer and use it in GitHub Desktop.
modifier_sync.py
"""
同じデータを持つオブジェクト同士でのModifier設定を同期します。
設定元となるオブジェクトを選択してスクリプトを実行してください。
他のオブジェクトはそのModifierの設定で上書きされます。
"""
import bpy
print("<script start>")
target_obj = bpy.context.view_layer.objects.active
print(f'target obj : {target_obj.name}')
target_data_name = target_obj.data.name
print(f'target data : {target_data_name}')
bpy.ops.object.select_all(action='DESELECT')
# Select all objects that are linked to the same data as the active object
for obj in bpy.data.objects:
if obj.type == "MESH" and obj.data.name == target_data_name:
obj.select_set(True)
print(f'select obj : {obj.name}')
# And activate target object
target_obj.select_set(True)
# Applies the active object's MODIFIER to all other selected objects
bpy.ops.object.make_links_data(type='MODIFIERS')
print("done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment