I downloaded a blend file from another user here with a script (for drivers) and a mesh + armature. On the driver of said mesh it says Error:invalid Python expression. I couldn't get it to work for so long although it worked for the user that sent it to me. However after a while I figured out a really odd fix.The fix is to move the armature then ctrl+z after I do that, the driver no longer shows an error instead it shows slow python expression which is fine as long as it works I guess.
Now I tried applying the script to a personal mesh+armature I copied the same exact drivers+variable. I get the Error:invalid Python expression. I tried doing the same odd fix that worked for some reason on the other mesh+armature but it didn't work in this case. Here's the script
import bpy
from mathutils import Vector
def left(self, z_rotation, speed_low, speed_high):
prev = self["prev_z"]
self["prev_z"] = z_rotation
delta = z_rotation - prev
if delta > 0:
self["z"] -= delta * speed_low
elif delta < 0:
self["z"] -= delta * speed_high
return self["z"]
def right(self, z_rotation, speed_low, speed_high):
prev = self["prev_z"]
self["prev_z"] = z_rotation
delta = z_rotation - prev
if delta < 0:
self["z"] += delta * speed_low
elif delta > 0:
self["z"] += delta * speed_high
return self["z"]
bpy.app.driver_namespace["left"] = left
bpy.app.driver_namespace["right"] = right
Here's the driver of the mesh I downloaded from the other user.
And this is the driver I applied to my own mesh(the exact same thing)
I have no clue why this is happening the issue is just really weird and very frustrating. Help would be immensely appreciated.
prev = self["prev_z"]
will throw an error. blender.stackexchange.com/questions/6173/… $\endgroup$