Easy Manipulation of origins scripting

Hi community,

I intend to make an addon to easily manipulate origins of selected objects (either move or rotate just the origin) as this is something I always wanted, and I need some tips and suggestions. I’m not asking for a complete code for this, as that’s what I want to do, just the things, or functions, or even topics that would help me to get it right. I am a C# developer, and I have a very little experience on python, so this will involve a lot of research for me. If someone experienced with scripting in Blender can give me some advice I would be very gratefull.

My expectation is to make a button, where when clicked it activates it, and it appears a manipulator on the location of the origin of the selected object, and with the orientation of that object, so as is moved, the origin of that object follows the position of that manipulator, and the same happens when rotated. It could be even better if I can make it work also with more than one object selected (all at the same time). When that button is clicked again, it should return to the “normal” mode (manipulator of origin no longer exists). I think it could be possible to do this, but difficult.

I’m thinking on creating an empty object when that button is activated, so this is the actual object that is manipulated, and the origin of the selected object should always follow it. When the button is disabled, that object should be removed. I don´t know if there is a better way than creating that object (I assume it could have some problems if for example turning that button off is forgotten). Also, I don’t know if in python there is something like events, so when the manipulator is changed, it executes an event that immediately updates the origin.

So what do you think I could better tackle this?

Thanks in advance!

The object’s origin is basically the object’s transform. If you move the origin, you move the object.

You can try move the mesh linked with the object in reverse for each frame when moving the object around, that will at least look like you are only moving the origin. But in actuality, moving the origin == moving the object.

Here is a list of API objects that may be involved:

bpy
bpy.context
bpy.context.selected_objects
bpy.context.active_object

<object pointer>.matrix_world
<object pointer>.matrix_local
<object pointer>.location

mathutils.Vector()
mathutils.Matrix()

Try them in the console to get a feel of what they are. You can also type in space in the console by holding down shift while pressing spacebar.

If you opt for Modal operators, you will have a lot more operator/input event objects to look at.

If you just go for a simple operator, then it’s much easier.

If you open Blender’s Text Editor, you can find the button for ‘Templates’, and there are many basic scripts about how to make operators. When you want to make the operator into an addon, you can look at existing addons in your blender directory for massive amount of informations. Blender is packed with examples.

Thank you!!! I will try it!