Recompute Drivers Button
I'm not really sure if this can be reproduced and what the real issue is, but I just noticed that every time I add a new custom property to the UI, it keeps disabling the previous one I added, then wise versa. The thing is that the drivers are fine on Blender side, but it just keeps disabling them in the UI and I don't know why. Basically if a property has value 1 in the UI, it stays at 0 in Blender and I have to readd the thing back to the UI to fix it, but it's now broken 3 times for seemingly no reason.
Edit: Well I looked further and noticed that somehow the currently problematic driver was throwing me the "invalid driver path" error, which I fixed by just clicking on the path, that then updated the driver and "fixed" the error, but this got me thinking that maybe the UI could have some kind of refresh button for all Blender drivers in case this happens.
This isn't actually the first time this has happened, I've tinkered with some other drivers in the past and for some reason Blender just likes to give these weird invalid driver errors occasionally, that then magically get fixed by just refreshing the path.
Hi!
Maybe I can add a button yes. Not sure how that can be done though, I have to check
I have a script that just reinserts the same driver variable name for all shape key drivers in the scene, that fixes the issue at least when it happens, but I don't know how to permanently prevent it though:
import bpy
# Function to refresh drivers by reinserting the variable names
def refresh_driver_variables():
# Iterate over all objects in the scene
for obj in bpy.data.objects:
# Check if the object has animation data with drivers
if obj.animation_data and obj.animation_data.drivers:
for fcurve in obj.animation_data.drivers:
# Get the driver object from the FCurve
driver = fcurve.driver
# Check if the driver has variables
if driver.variables:
for var in driver.variables:
# Save the current variable name
if var.name:
var_name = var.name
# Temporarily remove the variable name
var.name = ""
# Reinsert the saved variable name
var.name = var_name
# Print for debugging
print(f"Updated variable: {var.name} in driver of {obj.name}")
# Iterate over all objects for shape keys
for obj in bpy.data.objects:
if obj.data and hasattr(obj.data, "shape_keys") and obj.data.shape_keys:
shape_keys = obj.data.shape_keys
# Check if the shape key block has animation data with drivers
if shape_keys.animation_data and shape_keys.animation_data.drivers:
for fcurve in shape_keys.animation_data.drivers:
# Get the driver object from the FCurve
driver = fcurve.driver
# Check if the driver has variables
if driver.variables:
for var in driver.variables:
# Save the current variable name
if var.name:
var_name = var.name
# Temporarily remove the variable name
var.name = ""
# Reinsert the saved variable name
var.name = var_name
# Print for debugging
print(f"Updated variable: {var.name} in driver of shape key for {obj.name}")
# Run the function
refresh_driver_variables()
print("Driver variable refresh complete!")
No idea if you can implement it to the UI though and it's just for shape key drivers though
@J4ke6599 have you tried with simpler options, like
-
object.update_tag() -
bpy.context.view_layer.update() -
depsgraph = context.evaluated_depsgraph_get()together withobj.evaluated_get(depsgraph)
Refs
- https://docs.blender.org/api/current/bpy.types.Depsgraph.html