matrix.inverted() in a driver?

(I don’t know if posting this topic here is the appropriate section)
I need to use inverted values of a matrix on driver. Is that possible?

matrix_world[0][0] as a data path is working but not with the Python command matrix_world.inverted()[0][0].
Is it possible to do it in another way?

matrix_drivers.jpe (102 KB)


The problem here is that the object does not have the property matrix_world.inverted().
When you try to use such thing, you are in fact trying to compute something inside a variable. You are trying to invert the matrix.
Unfortunately the only place where you can perform computations in drivers is in “Expr:”.
At the moment the only thing that I managed to come up with is to write the full path to “Expr:”, so it would look something like this:

bpy.data.objects['Empty'].matrix_world.inverted()[0][0]

Unfortunately this will throw gazillion warnings at you, you’ll be advised to use variables instead and so on, so I’m not sure what problems such approach may cause.
The other issue is that you have to write eeeeeeeeverything with full paths in this one little line “Expr:”.
Will try to think about it a bit more, maybe I’ll come up with something

Thank you.
It’s working fine with full expression even with warnings. If there is no issues at render time, that’s OK for me.

I made some tests with custom python nodes and results are really great! Any property of an object can be passed to a socket with a python function. Inverted matrix is then really easy to setup and use. It works on the compositor and Cycles.


Cool!!! How did you do that?

I used the python nodes.
I almost finished it and will share the script when it’s done.

I sometimes wonder why Blender has Python drivers if you’re not supposed to use Python in them :wink: