global to local rotations

how do i?
i am trying to make something where i have 2 gears and i can rotate one along its local Z and the other will move accordingly in its local Z
i have been trying to do it as a driver seeing as it will update when there is a change in a var but i cant seem to find any way of doing it with out it being the active because that will not work

dam it all i keep seeing is this left/right matrix things but nothing on how to do it… other than to the left or the right and * by i think the other rot matrix

I’m not sure if this is what you were looking for or not, but here is how I did it:

Attachments


that will only work if it rotates on the global Z
i want the local of one rotating the local of the other

Dam it i will crack this thing -_-

ok i overlooked this page a lot but i think it works? that was WAY more simple than what i was going for lol
now how do i get what the local rotation is ?
import bpy
from mathutils import Matrix
from math import radians

ob = bpy.context.object
rot = Matrix.Rotation(radians(20), 4, ‘Z’)
ob.matrix_world *= rot