# how to origin to geometry in one axis?

I have many objects with misaligned origin and different Z scale. My origin of each object is located on Z = 0m coordinate. Is there way how to move origin to the center of the object while keeping Z location on 0m?

There is no vertex or polygon in the middle.

Adding new picture for better explanatory, hope it help

thanks

• Do they have a different Z scale as you wrote or a different Z location? And do you want the origin in the center (X, Y and Z) of the geometry or just move the geometry on the Z? Feb 8, 2023 at 10:16
• i don't understand the question. even the picture doesn't clearly illustrate the problem. voting to close as this is not clear. Feb 8, 2023 at 14:11
• Last question: origin XY-centered to the complete object or the bottom faces? Feb 8, 2023 at 15:35

I don't know python so am not sure if you could write code to go through all your objects and do the following, but: This is your original position

Go into Edit mode then Shift-S > Cursor to Selected to move the cursor to the centre of the object

Back in Object mode, bring up the N panel and on the View tab, set the 3D Cursor Z Location to 0 (zero).

Then Object > Set Origin > Origin to 3D Cursor should give the result you want:

• problem is that mine object is not centroid Feb 8, 2023 at 17:13
• That's why we needed more details in the question! Feb 8, 2023 at 17:28
• I have add new image to the question. Feb 8, 2023 at 17:46
• What do you mean by 'my object is not centroid'? If you mean that it's not a cube, my solution should work on any object because it snaps the cursor to the centre of the geometry of the object. Feb 8, 2023 at 17:51
• center of my object is not on the center of the axis, that's why i don't know where to send cursor Feb 8, 2023 at 18:02

To have the origin at the center of a mesh's geometry while keeping the origin in its location, you can right-click on the selected object(s) in Object Mode to bring up the Object Context Menu and choose Set Origin > Geometry to Origin.

Before:

After:

• Thanks for answer, my problem is id like to keep one axis not moved. I have add images into question. Feb 8, 2023 at 10:31
• In that case, just choose 'Set Origin to Geometry'. That will move the origin without touching the location of the object. Feb 8, 2023 at 11:45
• But it will change the local Z of the origin, which they do not want Feb 8, 2023 at 11:59
• Ah ok. How about setting the 3D cursor to the centre of the object (Shift-S > Cursor to Selected), setting the 3d Cursor Z location to zero in the N panel and then Object >Set Origin to 3D cursor? Feb 8, 2023 at 12:30
• I think we still need more details on exactly what the OP is trying to achieve before suggesting anything further, but yes, you would have to switch in and out of Edit mode for my suggestion which would be very time consuming for lots of objects. Feb 8, 2023 at 13:59

Fast and easy:

In sidebar/tool/affect only, enable both "origins" and "locations".

Plop a cursor down on the bottom of your mesh. Set pivot point to cursor. Set orientation to local.

Scale to 0 in Z axis. (Or whatever axis you want.)

Shown before and after. Don't forget to change your "affect only" options back before you start doing other stuff. Or, keep it on and repeat the operation for more objects; it's just a mouse click to plop a cursor and a single scale operation for each.

• hi, i don't understand what should do "Set orientation to local. Scale to 0 in Z axis. " And also how to keep cursor in the middle of the XY object. If I stich cursor to the bottom polygon it stick wherever I click Feb 10, 2023 at 9:28
• @barberik Orientation and pivot point are choices made in the top middle of your 3D viewport. To scale a selection to 0 in Z, type 's z 0' but not spaces and hit enter. And it doesn't matter where the cursor is in relationship to the local XY of the object, because you're only scaling to 0 in Z: you are keeping the existing origin of the object, but placing it on the bottom margin of your object, as determined by your placement of cursor. Feb 10, 2023 at 15:50

Since I have lot of objects I made some python shortcut based on John's answer

import bpy

bpy.ops.object.editmode_toggle()
bpy.ops.mesh.select_all(action='SELECT')

for area in bpy.context.screen.areas:
if area.type == 'VIEW_3D':
ctx = bpy.context.copy()
ctx['area'] = area
ctx['region'] = area.regions[-1]
bpy.ops.view3d.view_selected(ctx)
bpy.ops.view3d.snap_cursor_to_selected(ctx)

bpy.context.scene.cursor.location[2] = 0
bpy.ops.object.editmode_toggle()
bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')

bpy.context.object.location[0] = 0
bpy.context.object.location[1] = 0


edit: This process put origin to the center of object based on geometry weight not into bounding box center.