[Bf-extensions-cvs] [d2325587] master: Rigify: fix T99352 - generation issues when same named rig is linked.

Alexander Gavrilov noreply at git.blender.org
Mon Jul 11 19:32:06 CEST 2022


Commit: d2325587d73bc825986af3a1baba51cb4a9ce355
Author: Alexander Gavrilov
Date:   Mon Jul 11 20:32:12 2022 +0300
Branches: master
https://developer.blender.org/rBAd2325587d73bc825986af3a1baba51cb4a9ce355

Rigify: fix T99352 - generation issues when same named rig is linked.

Only consider local datablocks when searching for the rig object,
widget collection and widget objects themselves during generation.

===================================================================

M	rigify/generate.py
M	rigify/utils/collections.py
M	rigify/utils/widgets.py

===================================================================

diff --git a/rigify/generate.py b/rigify/generate.py
index 3acc2e40..53b47b00 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -76,7 +76,7 @@ class Generator(base_generate.BaseGenerator):
             target_rig.display_type = 'WIRE'
 
         # If the object is already added to the scene, switch to its collection
-        if target_rig.name in self.context.scene.collection.all_objects:
+        if target_rig in list(self.context.scene.collection.all_objects):
             self.__switch_to_usable_collection(target_rig)
         else:
             # Otherwise, add to the selected collection or the metarig collection if unusable
@@ -117,11 +117,14 @@ class Generator(base_generate.BaseGenerator):
         wgts_group_name = "WGTS_" + self.obj.name
         old_collection = bpy.data.collections.get(wgts_group_name)
 
+        if old_collection.library:
+            old_collection = None
+
         if not old_collection:
             # Update the old 'Widgets' collection
             legacy_collection = bpy.data.collections.get('Widgets')
 
-            if legacy_collection and wgts_group_name in legacy_collection.objects:
+            if legacy_collection and wgts_group_name in legacy_collection.objects and not legacy_collection.library:
                 legacy_collection.name = wgts_group_name
                 old_collection = legacy_collection
 
diff --git a/rigify/utils/collections.py b/rigify/utils/collections.py
index 8a299a9b..9eeaac51 100644
--- a/rigify/utils/collections.py
+++ b/rigify/utils/collections.py
@@ -53,7 +53,7 @@ def ensure_collection(context, collection_name, hidden=False) -> bpy.types.Colle
     active_collection = active_layer_coll.collection
 
     collection = bpy.data.collections.get(collection_name)
-    if not collection:
+    if not collection or collection.library:
         # Create the collection
         collection = bpy.data.collections.new(collection_name)
         collection.hide_viewport = hidden
diff --git a/rigify/utils/widgets.py b/rigify/utils/widgets.py
index e02f3387..ca207ddc 100644
--- a/rigify/utils/widgets.py
+++ b/rigify/utils/widgets.py
@@ -86,6 +86,9 @@ def create_widget(rig, bone_name, bone_transform_name=None, *, widget_name=None,
         if not obj:
             # Search the scene by name
             obj = scene.objects.get(obj_name)
+            if obj.library:
+                local_objs = [obj for obj in scene.objects if obj.name == obj_name and not obj.library]
+                obj = local_objs[0] if local_objs else None
 
         if obj:
             # Record the generated widget



More information about the Bf-extensions-cvs mailing list