Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bl_info = {
- "name": "Set Default Mirror Modifier Merge Distance",
- "author": "ggthb",
- "version": (1, 0),
- "blender": (3, 0, 0),
- "location": "Modifiers > Mirror Modifier",
- "description": "Sets the default merge threshold for the Mirror Modifier to 0.0001 meters",
- "category": "Modifiers",
- }
- import bpy
- from bpy.app.handlers import persistent
- from bpy.types import Operator
- # Function to set the merge threshold for Mirror Modifiers
- def update_mirror_modifier_merge_threshold(modifier):
- if modifier.type == 'MIRROR':
- modifier.merge_threshold = 0.0001
- # Handler to apply settings to new modifiers
- @persistent
- def on_modifier_add(scene):
- # Iterate over all objects in bpy.data.objects
- for obj in bpy.data.objects:
- for modifier in obj.modifiers:
- # Set merge threshold for new or unmodified Mirror Modifiers
- if modifier.type == 'MIRROR' and modifier.merge_threshold != 0.0001:
- modifier.merge_threshold = 0.0001
- # Operator to apply the setting to existing Mirror Modifiers
- class OBJECT_OT_SetMirrorMergeThreshold(Operator):
- bl_idname = "object.set_mirror_merge_threshold"
- bl_label = "Set Mirror Merge Threshold"
- bl_description = "Sets the merge threshold to 0.0001m for all Mirror Modifiers in the scene"
- def execute(self, context):
- for obj in bpy.data.objects:
- for modifier in obj.modifiers:
- update_mirror_modifier_merge_threshold(modifier)
- # Save user preferences to persist changes
- bpy.ops.wm.save_userpref()
- return {'FINISHED'}
- def register():
- # Register the operator
- bpy.utils.register_class(OBJECT_OT_SetMirrorMergeThreshold)
- # Append the handler to check for new modifiers
- bpy.app.handlers.depsgraph_update_post.append(on_modifier_add)
- # Apply to existing modifiers on startup
- for obj in bpy.data.objects:
- for modifier in obj.modifiers:
- update_mirror_modifier_merge_threshold(modifier)
- def unregister():
- # Unregister the operator
- bpy.utils.unregister_class(OBJECT_OT_SetMirrorMergeThreshold)
- # Remove the handler
- if on_modifier_add in bpy.app.handlers.depsgraph_update_post:
- bpy.app.handlers.depsgraph_update_post.remove(on_modifier_add)
- if __name__ == "__main__":
- register()
Advertisement
Add Comment
Please, Sign In to add comment