Skip to content

Commit

Permalink
feat: add traditional (now default) and faux origin translation to se…
Browse files Browse the repository at this point in the history
…t_origin utility
  • Loading branch information
tristan-hm committed Apr 23, 2022
1 parent a21a46c commit 5122bae
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion utils/set_origin.py
Original file line number Diff line number Diff line change
@@ -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'}


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5122bae

Please sign in to comment.