2
$\begingroup$

At the moment, when I resize or modify an object, I manually click Set Origin -> Origin to Geometry to recentre the manipulators in the object's bounds.

Like so:

enter image description here

My desire is to have the origin always centered to the object as it changes. Is there any way of just having Blender do this automatically?

$\endgroup$
  • $\begingroup$ Never heard of that. Why would you need that feature? Maybe we can think up a workaround? Try binding a shortcut? Alt Shift C or something like that. $\endgroup$ – Jude Desir Dec 8 '18 at 0:26
  • $\begingroup$ @JudeDesir I'm doing a lot of blockout work for geometry. This involves lots of pieces that I'm constantly resizing, making longer, thinner...etc. My desire is to always have the manipulators positioned at the centre of the object for ease of use. It would just save time. Any manual input that is required to reposition the origin is, exactly that, manual input. It extends the workflow. I want to know if there is a more automated way of having Blender help me out so its one less thing I have to constantly do. $\endgroup$ – Temmy Dec 8 '18 at 11:39
0
$\begingroup$

Scripting

enter image description here Test run, Shift select 3 objects, extends middle to "kiss" outer

Test script:

Select 3 objects, extends the active (middle) to the outer objects. Click the "run script" button to run.

import bpy
import bmesh
context = bpy.context

def kiss_faces(ob, target):
    mw = ob.matrix_world
    mwi = ob.matrix_world.inverted()
    v = mwi @ target.matrix_world.translation
    if v.length < 1e-5:
        return 
    f = sorted(ob.data.polygons, key=lambda p : (p.center - v).length)[0]

    pt = target.matrix_world.inverted() @ ob.matrix_world @ f.center
    hit, loc, norm, idx = target.closest_point_on_mesh(pt)  

    if hit:

        d = (ob.matrix_world.inverted() @ target.matrix_world @ loc - f.center).length * f.normal 
        for i in f.vertices:
            ob.data.vertices[i].co += d
        ob.data.update()

o = context.object
a, b = [o for o in context.selected_objects if o.type == 'MESH' and o is not context.object]
assert(o == context.object)

kiss_faces(o, a)
kiss_faces(o, b)
bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')

Note script above for 2.8, for 2.7x, hit CtrlF enter image description herein blender text editor and replace all occurrences of ampersand @ with asterisk *

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.