Set origin to selected

Crikey this exists, THANK YOU! This should be an option by default! Where has this been all my life…

Thanks dude :slight_smile:

Hi ghigi, i was revisiting this functionality to make it a little bit more versatile and came up with this:

Alt + C only works with meshes cos it collides with Alt C on edit curve. So if the shortcut were Alt + Shift + C, you can:

  • Make the addon work with any kind of object, curves, armatures, etc. (set the origin to a curve handle and such)
  • On Object mode use the cursor instead whatever is selected.

This would be the operator.


class OBJECT_OT_smart_origin_set(bpy.types.Operator):
    """Sets objects origin on edit mode"""
    bl_idname = "object.smart_origin_set"
    bl_label = "Sets objects origin"

    @classmethod
    def poll(cls, context):
        return context.object is not None

    def execute(self, context):
        obj = context.object
        #restoring cursor position doesnt work on Blender 2.76
        #loc = context.scene.cursor_location
        editmode = context.mode != "OBJECT"
        
        if editmode:
            bpy.ops.view3d.snap_cursor_to_selected()
            bpy.ops.object.mode_set()
        
        bpy.ops.object.origin_set(type = "ORIGIN_CURSOR")

        if editmode:
            bpy.ops.object.editmode_toggle()
            #context.scene.cursor_location = loc
        return {'FINISHED'}

Thanks to bring something like this to our attention.

So helpful! Thank you!

Unfortunately, it doesn’t seem to work in 2.79 anymore. It can be installed, but after enabling it, it throws this error:

Traceback (most recent call last):
File “D:\GrafikaSSD\Blender\2.79\scripts\modules\addon_utils.py”, line 350, in enable
mod.register()
File “C:\Users\Slimaci\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\object_origin_to_selection_revamp.py”, line 72, in register
kmi = km.keymap_items.new(‘object.smart_origin_set’,‘C’,‘PRESS’,False,False,False,True,False)
AttributeError: ‘NoneType’ object has no attribute ‘keymap_items’

EDIT: After some further testing I found out that despite the error above, it appears in Spacebar search menu and it does seem to work correctly from there, however it remains in the menu just for the duration of that session.
Therefore, to use it in 2.79 it has to be installed and turned on every time you launch Blender.

Thanks!!!

It works for me in 2.79, when you enable it, make sure to Save User Settings

It would be great to port it to 2.80!

1 Like

Definitely would love to see this in 2.8 :slight_smile:

You can always use iOps for this. Does exactly the same thing and more besides. One of my favorite addons. F4 in edit mode will set origin to selected. interactionOps [iOps]

Hope this helps.

1 Like

thanks! :slight_smile:

Anyone can port this to 2.8 its one of my favorite addons, I tried iOps but it leaves edit mode after origin change and has features that override blender default hotkeys f1-f4, specially f4 which is preferences pop up.

I asked one of my friends and he managed to do that actually! You can download it from here:
Set origin to selection - 2.80:
(edited - fixed version):
https://drive.google.com/file/d/1ytYWkaHkuSBMHL66NHjla0_Du3I6IgYR/view?usp=sharing

1 Like

I tried it with the newest 2.8 gives this kinda error https://i.imgur.com/oKNWdnB.png

Nice, iOps is perfect for me! Thanks so much :slight_smile:

Yes, there was some change in Blender in the meantime. Try fixed version: https://drive.google.com/file/d/1ytYWkaHkuSBMHL66NHjla0_Du3I6IgYR/view?usp=sharing

2 Likes

works like charm! Thanks for keeping this addon alive

Nice addon simple to use

awesome addon :slight_smile:
but one problem, after restart blender, addon stop working and need to instal again or off/on

Yeah, plus Blender not save the new hotkey of Add-on.