Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2021-07-20 12:18:03 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2021-07-20 12:18:10 +0300
commite4d9cf84d00a6d223af3c89073858547090217ef (patch)
treeb161fc6f8d494afed440b04442e1c88123f8485d /rigify/utils
parent1adb56d8b01cf1327f58c6fb8b1ccc8b7efd76ad (diff)
Rigify: clear driver errors after generation.
In the process of re-generating a rig, drivers that reference it from other objects can temporarily become invalid. This sets an error flag in the driver, stopping its evaluation, so the error doesn't clear out even when it becomes valid again. To fix stuck drivers, loop over all objects in the file after generation and refresh their drivers by fake modification.
Diffstat (limited to 'rigify/utils')
-rw-r--r--rigify/utils/mechanism.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/rigify/utils/mechanism.py b/rigify/utils/mechanism.py
index 413d8a00..92e161f6 100644
--- a/rigify/utils/mechanism.py
+++ b/rigify/utils/mechanism.py
@@ -21,6 +21,8 @@
import bpy
import re
+from bpy.types import bpy_prop_collection, Material
+
from rna_prop_ui import rna_idprop_ui_create, rna_idprop_ui_prop_get
from rna_prop_ui import rna_idprop_quote_path as quote_property
@@ -519,6 +521,38 @@ def copy_custom_properties_with_ui(rig, src, dest_bone, *, ui_controls=None, **o
#=============================================
+# Driver management
+#=============================================
+
+def refresh_drivers(obj):
+ """Cause all drivers belonging to the object to be re-evaluated, clearing any errors."""
+
+ # Refresh object's own drivers if any
+ anim_data = getattr(obj, 'animation_data', None)
+
+ if anim_data:
+ for fcu in anim_data.drivers:
+ # Make a fake change to the driver
+ fcu.driver.type = fcu.driver.type
+
+ # Material node trees aren't in any lists
+ if isinstance(obj, Material):
+ refresh_drivers(obj.node_tree)
+
+
+def refresh_all_drivers():
+ """Cause all drivers in the file to be re-evaluated, clearing any errors."""
+
+ # Iterate over all datablocks in the file
+ for attr in dir(bpy.data):
+ coll = getattr(bpy.data, attr, None)
+
+ if isinstance(coll, bpy_prop_collection):
+ for item in coll:
+ refresh_drivers(item)
+
+
+#=============================================
# Utility mixin
#=============================================