0

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

enter image description here

thanks

barberik
  • 129
  • 1
  • 9

4 Answers4

2

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 enter image description here

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

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

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

John Eason
  • 4,745
  • 1
  • 6
  • 9
  • problem is that mine object is not centroid – barberik Feb 08 '23 at 17:13
  • 1
    That's why we needed more details in the question! – John Eason Feb 08 '23 at 17:28
  • I have add new image to the question. – barberik Feb 08 '23 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. – John Eason Feb 08 '23 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 – barberik Feb 08 '23 at 18:02
  • I don't think we can help you in that case. – John Eason Feb 08 '23 at 19:22
  • @barberik What do you mean by saying "center of my object is not on the center of the axis"? You select all of the object's mesh in Edit Mode, then Shift+S > Cursor to Selected, then go to the cursor properties and manually type in 0 for the Z location, then afterwards in Object Mode set the origin to the cursor. Don't know what you need the "center of the axis" for. – Gordon Brinkmann Feb 09 '23 at 07:31
  • yesterday I was missing some part of your answer, today I found it as right way to go. Thanks! – barberik Feb 09 '23 at 11:40
  • Phew! Thanks for the confirmation! :^)) – John Eason Feb 09 '23 at 14:23
0

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:

before setting the origin

After:

after geometry to origin

Gordon Brinkmann
  • 28,589
  • 1
  • 19
  • 49
  • Thanks for answer, my problem is id like to keep one axis not moved. I have add images into question. – barberik Feb 08 '23 at 10:31
  • In that case, just choose 'Set Origin to Geometry'. That will move the origin without touching the location of the object. – John Eason Feb 08 '23 at 11:45
  • But it will change the local Z of the origin, which they do not want – Gorgious Feb 08 '23 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? – John Eason Feb 08 '23 at 12:30
  • @JohnEason That could be a solution. It is very tedious if you have multiple objects, but better than nothing. When I wrote my answer it wasn't really clear what was the goal, so I'll just leave it here for someone with similar problems. But I would suggest you put your answer here, too. Although this changes the X and Y location of the origin - I'm still not sure if that would be okay or if the mesh has to move on X and Y. – Gordon Brinkmann Feb 08 '23 at 12:35
  • But you have to set the cursor to the selected mesh in Edit Mode, otherwise it would just move to the origin so this wouldn't help anything. – Gordon Brinkmann Feb 08 '23 at 12:38
  • 1
    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. – John Eason Feb 08 '23 at 13:59
  • @JohnEason Reading the question once again I think I get it now... your solution should work. Question says: "move origin to the center of the object while keeping Z location on 0m" – Gordon Brinkmann Feb 08 '23 at 14:12
  • I have add some more images, sorry for my bad explanatory ability – barberik Feb 08 '23 at 15:14
0

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.)

enter image description here

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.

Nathan
  • 24,535
  • 1
  • 22
  • 68
  • 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 – barberik Feb 10 '23 at 09: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. – Nathan Feb 10 '23 at 15:50
0

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. enter image description here

barberik
  • 129
  • 1
  • 9