snapping object origins of multiple object to same heigth

Hello, i have a qeustion.

i have many objects and the origins of those objects are all over the place and i need to get each origin of each object on a particular height and that for many objects at the same time, i know i could just do origin to geometry but then the origin is at the center of the mesh while i want it on the bottom of the mesh. also i could do each object individually by snapping the cursor to the bottom of the mesh but i want to do this for all the objects in one time.

does anybody know of a way to do this?

select al ob
then spacebar align
and ni tool panel select axis needed!

salutations

actually i don´t need the object to be aligned i need the origin of the objects to be aligned on the same height so only vertically. does anyone knows?

Hi :slight_smile:
Select all the objects you want to align, then along the bottom of the 3D viewport select this button:



Then scale the objects on whichever axis you need to 0. And that should do it :slight_smile:
Once you’re done remember to turn off the button again, otherwise you’ll find you can’t scale or rotate things.

Hopefully this helps :slight_smile:
Jamie

nope that really did not do anything for me, remember i am trying to change to origin of objects not objects itself.
the origin is the little dot that symbolizes the point of an object that represent the origin, when you select an object its the orange dot, so again basically i am trying to change the origins of many objects on the z axis at once, so that i do not have to do it individually.
perhaps it is just not possible, well i hope somebody still might know a way

there might be a script to do that
if not then a script can be made to do that
so ask in python forum and if it exist or somone can make a script to do that
should not be difficult!

salutations

So you want all the origins to have the same z value? say 1.75, Well it’s kind of hacky but I think it’ll work.
Select first object, Object->snap->cursor to selected
Add an empty, in transform, set the z value for the empty, 1.75
Object->snap->cursor to selected
Select your first object.
In Object Tools, click origin -> origin to 3-d cursor

Repeat with other objects. Delete the empties.

You might be able to join all the objects into one mesh by selecting them with CTRL-J. All the separate meshes now have the same origin, which you can move (transform) where you want it to be. Now TAB into edit mode and press P to separate back into separate objects. One of the options is “By loose parts,” which creates new objects out of all disconnected meshes. Presto! They all keep the same origin.

actually to do this for one object at the time is actually very easy, you select object and go into edit mode, select two vertices at the bottom of the mesh, snap cursor to selection, go back into object mode and snap the origin to cursor,
i think this would be faster then your method unless i have understood you wrong. the thing is that i am trying to do this procedure for many objects at once, for example i select all the object and snap the origin of all those objects at the same time to the geometry, but then somehow i need to get the origin of all the same objects at the same time on the same height.

thanks for the advance but that also will not work because i do need the origins of all the objects to the at the exact same location, just the same height. also my objects have different loose parts so doing this would be a disaster. you know what is also strange is that you cannot hotkey the function of snapping origins, which i find really strange, really should be possible i think, perhaps a script is the only way, but i cannot program unfortunately. perhaps i can ask in the script section here.

anyways thanks for all your input fellow blenderheads,

I wrote a script for this. See if it can help.



"""
Move object origins to lowest Z point
Usage:
    - Select objects (only moves mesh object origins from those)
    - Apply rotation and scale (ctrl+a -> rotation & scale)
    - Move object origins to geometry (ctrl+alt+shift+c -> origin to geometry)
    - Run script
"""

import bpy 
import mathutils
from mathutils import Vector

objects = bpy.context.selected_objects

for obj in objects:
    if(obj.type == "MESH"):
                
        vertex_coordinate = ""
        for vertex in obj.data.vertices:
            if((vertex_coordinate == "") or (vertex.co.z < vertex_coordinate.z)):
                vertex_coordinate = vertex.co
        
        vertex_global_coordinate = obj.matrix_world * vertex_coordinate
        offset = (obj.location.x, obj.location.y, vertex_global_coordinate.z)
        new_location = offset
        offset = Vector(offset)
        offset = offset - obj.location
        
        for vertex in obj.data.vertices:
            vertex.co = vertex.co - offset
        
        obj.location = new_location

how does it work ?

tried with objects far away from each other and N-1 ob are changing centers orig
but ob don’t move
also don’t work on suzanne !
or may be last ob !

thanks

Instructions are on top of the script.

That’s a feature. Last line keeps the object at the original location. If you want the objects aligned, scale them to 0 along an (z) axis with manipulate object centers only (alt+period) enabled.
This allows you to choose if you want them aligned or if you want to put them in one place for grouping particle objects for example. It keeps the script more general and readable that way and it’s easier to adapt to other things.

Tried it with a new scene. It works when the instructions are followed. For some reason it won’t get the correct values with the monkey head before that

if suzanne is last ob it does not change the origin on it!

i guess moving only orig would also mean that most objects should be about at the same level plus or minus a small amount!

i’ll keep it in mind might be usefull in futur who knows!

thanks

You didn’t follow the instructions and apply the rotation and scale. When you add a monkey head, it has 90° rotation on X-axis.


sorry you mean that you have to manually apply rot scale before exec script!
i tought this was done inside the script itself!

i will add it !

strange did not know that suzanne ahd a rot X 90!

thanks

WOW JA12,

that is exactly what i meant. amazing magic you just did there, i am not a programmer, but being able to do this sure has many benefits.
thanks a lot man. you saved me a bunch of time. once i finishe my modelling project i will give you a copy of the model that i am working on, so please if you want you can give me your email so once it is ready i will send you a download link.
many thanks again, happy blending :slight_smile:

JA12, i just have another question, do you know if there is a script around somewhere that can recalculate the normals of many objects at the same time, so basically recalculate the normals in object mode?

You could join bunch of objects temporarily, recalculate normals in edit mode and then separate but that might not be optimal in your case. The object names would be lost and you mentioned that there are loose vertices. Recalculating might not work if your meshes are non-manifold and loose geometry would also be separated with that.

Doing that with a script is straightforward enough. This does basically the same as you would do one by one: select object, go to edit mode, select all vertices, recalculate normals outside, back to object mode. But again, if your mesh is non-manifold, the normals calculation might not work.


import bpy 

for obj in bpy.context.selected_objects:
    if(obj.type == "MESH"):
        bpy.context.scene.objects.active = obj
        bpy.ops.object.mode_set(mode='EDIT')
        bpy.ops.mesh.select_all(action='SELECT')
        bpy.ops.mesh.normals_make_consistent(inside=False)
        bpy.ops.object.editmode_toggle()

wow worked like a charm, i think you might have saved me like a million mouse clicks with this.
thank you so much.