diff --git a/utils/set_origin.py b/utils/set_origin.py index 98a3045..26f13d8 100644 --- a/utils/set_origin.py +++ b/utils/set_origin.py @@ -1,11 +1,13 @@ import bpy from mathutils import Vector +from .. lib.objects import set_origin class ND_OT_set_origin(bpy.types.Operator): bl_idname = "nd.set_origin" bl_label = "Set Origin" - bl_description = "Set the origin of the active object to that of another" + bl_description = """Set the origin of the active object to that of another +ALT — Use faux origin translation (for origin-reliant geometry)""" bl_options = {'UNDO'} @@ -35,6 +37,19 @@ def execute(self, context): return {'FINISHED'} + def invoke(self, context, event): + if event.alt: + return self.execute(context) + else: + a, b = context.selected_objects + reference_obj = a if a.name != context.object.name else b + + mx = context.object.matrix_world + set_origin(reference_obj, mx) + + return {'FINISHED'} + + def add_displace_modifier(self, reference_obj, axis, strength): displace = reference_obj.modifiers.new("{} Axis Displace — ND".format(axis), 'DISPLACE') displace.direction = axis