0
$\begingroup$

in my Blender 2.92 scene file, you can find the numeric input in the top left corner of the viewport (important, the numeric input only shows when transforming an object). what i'm inquiring about, is the local information displayed by the numeric input. using the cube with a random orientation, i can transform the object a distance of 1 unit along the local y axis ...regardless of the objects orientation, the numeric input will then display a distance value of 1 (or -1 depending on the direction we moved the object) as well as the normalized distance value of 1. although the transform channels themselves update to reflect the objects new world position, i'm actually trying to save that distance value from the numeric input.

does anyone know if this information is stored somewhere? i'm specifically looking to create a custom property that stores the distance values, and it needs to update based on user input in real-time. i'm understanding this as something that could become quite complex to develop from scratch, but the numeric input already shares all of this information in real-time. any insight into this inquiry is much appreciated!

enter image description here

$\endgroup$
2
  • $\begingroup$ Moving an object in the 3D viewport with a local orientation does not move it in its local axis. That's doubtlessly confusing, but true. An object's local transform moves, then rotates. That's why all three numbers change-- you're not actually moving it 1 unit in its local Y axis, you're moving it in a different space than that. You can evaluate the motion in some other space, but is that space its rotation on the previous frame, or on the next frame? They are not necessarily the same space. $\endgroup$
    – Nathan
    Apr 6, 2021 at 21:22
  • $\begingroup$ the local transformation value is better described as distance. i'm not looking to gather transformation values, but instead am looking to get the distance between it's current position compared to it's previous position. currently the numeric input displays this information, and it's updated based on users real-time input. we can't create wheel rigs without this information unless we create dependencies. in maya we use the expression editor to overwrite dependencies, and those expressions work in real-time just as the numeric input does here. $\endgroup$ Apr 6, 2021 at 22:08

2 Answers 2

1
$\begingroup$

From the window manager's operators collection.

A very simplistic answer to how to get the values used in the transform translate operator. Other things to consider would be looking for edit mode switches. How to keep track of what objects have context at the time etc

Looking in info area after translating will see the python name of the operator, from which we can get the idname

>>> bpy.ops.transform.translate.idname()
'TRANSFORM_OT_translate'

Make some moves.

Translate 4 locally in $Y$ GYY 4 ,then -5 locally in $X$ GXX -5 and finally 3 in $Z$ GZZ 3

Get the details from python console.

Off to the python console, and get the details of the translations made using operator via UI above.

>>> wm = C.window_manager

>>> for op in wm.operators:
...     if op.bl_idname.startswith('TRANSFORM'):
...         props = op.properties
...         props.orient_type, props.value
...         
('LOCAL', Vector((0.0, 4.9, 0.0)))
('LOCAL', Vector((-5.0, -0.0, -0.0)))
('LOCAL', Vector((0.0, 0.0, 3.0)))

Another option is

>>> wm.operator_properties_last("transform.translate")
<bpy_struct, TRANSFORM_OT_translate at 0x7f0df251cb48>

>>> props = wm.operator_properties_last("transform.translate")
>>> props.value
Vector((0.0, 0.0, 3.0))
$\endgroup$
0
$\begingroup$

Your comment indicated that you're not really interested in directional transformations, but only in distance. You can get this, but it's probably not as easy as you want to get in Blender, because it's a temporal value-- based on values from different frames.

Select your cube. Animate it however. Duplicate the cube and make the duplicate non-rendering. In the graph editor, select all of your duplicates keyframes and move -1 units in the X axis. Give your custom property a driver based on the distance from your original to your duplicate.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.