5
$\begingroup$

Is there a way to make the origin of any new object appear by default at the lowest point of that object?

The center of the lowest face for a cube, for example. It's very uncomfortable to transform objects and lose their position on the ground (or anywhere else). Every slight transformation makes me to snap this object again. I know I can move pivot manually or just move the upper face (if any) in edit mode, but it's still more moves than I want. Also there is a "cage transformation", but it often uses wrong rulers for transformation for some reason.

$\endgroup$
10
$\begingroup$

Run a script using msgbus when new primitive added

enter image description here

Run the following script in the text editor.

Add any mesh primitive, the origin is adjusted to the bottom of its bounding box as long as the following conditions are met.

  • Object mode.
  • Object is a mesh.
  • The active operator is a mesh primitive add.

Code put together from

Set origin to bottom center of multiple objects

Adjusted such that the object is not moved globally so the mesh origin is at scene cursor location, and is the centre of the bottom face of bounding box. (For Suzanne is outside the mesh) Alternatively running this one after adding objects does the trick, but not "automatically".

How to get an event when an object is selected?

Very lacking in docs re bpy.msgbus, not sure for what version was introduced, possibly should assert(bpy.msgbus) to throw an error if not available for your version.

import bpy
from mathutils import Vector, Matrix

handle = object()

# Triggers when an object is made active
subscribe_to = bpy.types.LayerObjects, "active" # 

def origin_to_bottom(ob):
    me = ob.data

    local_verts = [Vector(v[:]) for v in ob.bound_box]
    o = sum(local_verts, Vector()) / 8
    o.z = min(v.z for v in local_verts)

    me.transform(Matrix.Translation(-o))


def notify_test(context):
    if (context.object.type == 'MESH'
            and getattr(context.active_operator, "bl_idname", "").startswith("MESH_OT_primitive_")
            and context.mode == 'OBJECT'):
        print("Setting origin to bottom")
        origin_to_bottom(context.object)

bpy.msgbus.subscribe_rna(
    key=subscribe_to,
    owner=handle,
    args=(bpy.context,),
    notify=notify_test,
)

bpy.msgbus.publish_rna(key=subscribe_to)

Note: put this together as a proof of concept. Have not tested greatly.

Could modify to only work for Cube, Cylinder, Cone not Monkey Sphere.

Having the origin at centre of lowest face would be Ok for cube not UV cylinder, Cone with ngon fill, not fan etc.

Alternatively could rewrite, or override (ie register another with same name), any / all the add mesh operators in python.

$\endgroup$
2
  • $\begingroup$ That worked like a charm :) Thank you batFINGER! $\endgroup$
    – satishgoda
    Jan 29 '20 at 17:46
  • $\begingroup$ Wow, you really made a great work, I even wasn't hoping =) Thanks! $\endgroup$
    – Wizarmoon
    Jan 31 '20 at 13:58
2
$\begingroup$

Unfortunately, there is no way to change the default location of the origin.

Perhaps I can help quicken the process of moving the origin for you though.

Open the sidebar usingN, switch to the "Tool" tab, and under Affect only select Origins. Then, with the target object selected, press G to grab/move the origin, Z to lock movement to the Z-axis, and hold Ctrl to snap the origin to the bottom of the object. If you need to change snapping mode, press Ctrl+Shift+Tab and select face snapping mode in the popup menu.

When moving objects you want to keep on the ground plane, you can press Shift+Z to move the object in the XY-plane only.

In regards to the scale cage, refer to the documentation for it here.

$\endgroup$
1
  • $\begingroup$ Thanks! I already know this way and use it. Actually, I am using Bforartists (it's slightly transformed Blender with more usability), and these options are clearly visible there. I hoped there is some option to change in files to make the pivot appear at the lowest point. $\endgroup$
    – Wizarmoon
    Dec 25 '19 at 5:02

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.