I am working on a code that requires the origins of an object to be the same as another object. May I know if there is any way I can manipulate the origins directly? I also tried to do the manual method to write a script snapping 3D cursor to selected, and then snapping origins to 3D cursor, but it isn’t working (something about having overriding operators that depend on context, don’t really understand).
So, if anyone knows how I can extract an object’s origins data, please enlighten me. Thanks!
Objects are basically an anchor for some data. They are the ‘origin’ (in world space), and data relates to this origin (in object space).
So the origin of an object is represented by its location, scale and rotation, or by its world matrix (which encodes all three transformations.
Since data (for example, a mesh) is directly related to the object’s origin, any transformation to the origin will be reflected in the data. So if you want to move the origin 1 unit in the X axis, you’ll need to move the data -1 unit in that same axis (the inverse transformation) in order to keep things in the same place.
Thanks for the explanation, I understand this concept. Maybe the terms I have used were not too accurate; I was just wondering if there is a way I can get the location data of an object, and then get another object to have its origins onto the location. So for example:
obj01 is at (3,3,3)
obj02 is at (0,0,0)
obj02 to snap its origin to (3,3,3) without the mesh position moving
How I would do it manually is to set my 3D cursor to selected (obj01), and then select obj02 and set origin of obj02 to 3D cursor:
But the code above apparently does not work, and from what I understand it has got something to do with the 3D viewport. Basically, I need both objects to share the same origin so that when I make rotations, it will follow the same pivot point without doing a median of the 2 origins. Much appreciated if you could enlighten me if there’s any other way to go about doing this. Thanks!
Because those operators are Editor specific… they aren’t supposed to run in other situations.
That’s the problem!! The mesh position needs to move!!
If obj02’s origin moves to [3,3,3], so will all vertices that use that origin as, well, origin!
To keep the vertices in the same place (in world coordinates), you need to move all vertices by [-3,-3,-3] (in object coordinates)