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:
authorDemeter Dzadik <Mets>2022-07-12 17:28:14 +0300
committerAlexander Gavrilov <angavrilov@gmail.com>2022-07-12 18:13:37 +0300
commit144dbedd9f72b80793541703f3041daae81e3c4f (patch)
tree7e510d1e81b4492164bb93a164c90c907c0efae7
parent9f59c24f1f3b75550a8189bf4080cc7e19838837 (diff)
Rigify: Allow entering name on first generation
Requested by @dexon, see rBAece39d809ce#339214. This patch tries to improve a workflow that was hurt by D11356. One of the goals of that patch was to make the connection between metarig and generated rig stronger and more reliable, by using datablock pointers rather than text-based matching. This allows users to rename their datablocks as they would do with any other datablock in Blender, so there's much more freedom with naming when working with one metarig per generated rig per file. However, this made it hard to duplicate the metarig, make changes to it, and make a new rig out of it within the same file. Renaming several datablocks in this case is not an "option", but an unintuitive necessity. With the patch applied, when the metarig has no target rig, there is an option to input a rig name. If something is input by the user, that name will be used for the rig, the widget collection (by extension the widget objects) and the rig script, as long as they are not specified. So, while still requiring a few more clicks than before, the workflow for duplicating metarigs to make new ones is now much more reasonable: - Duplicate metarig, make changes - Remove the datablock references - Input a rig name - Generate If the a rig object with the same name already existed, it will NOT be overwritten, and the generated rig will have a .001 suffix. This matches the "new" option of the removed "new/overwrite" options. Meanwhile, the other workflow of having one metarig per generated rig per file is not affected at all: The text box for the name input can simply be ignored on the first generation. It will not show up after that, since you would never remove the target rig in this workflow. Differential Revision: https://developer.blender.org/D14757
-rw-r--r--rigify/__init__.py8
-rw-r--r--rigify/generate.py4
-rw-r--r--rigify/rig_ui_template.py3
-rw-r--r--rigify/ui.py8
4 files changed, 18 insertions, 5 deletions
diff --git a/rigify/__init__.py b/rigify/__init__.py
index 10e90b4c..8a45ae05 100644
--- a/rigify/__init__.py
+++ b/rigify/__init__.py
@@ -550,14 +550,18 @@ def register():
name="Widgets Collection",
description="Defines which collection to place widget objects in. If unset, a new one will be created based on the name of the rig")
+ bpy.types.Armature.rigify_rig_basename = StringProperty(name="Rigify Rig Name",
+ description="Optional. If specified, this name will be used for the newly generated rig, widget collection and script. Otherwise, a name is generated based on the name of the metarig object by replacing 'metarig' with 'rig', 'META' with 'RIG', or prefixing with 'RIG-'. When updating an already generated rig its name is never changed",
+ default="")
+
bpy.types.Armature.rigify_target_rig = PointerProperty(type=bpy.types.Object,
name="Rigify Target Rig",
- description="Defines which rig to overwrite. If unset, a new one called 'rig' will be created",
+ description="Defines which rig to overwrite. If unset, a new one will be created with name based on the Rig Name option or the name of the metarig",
poll=lambda self, obj: obj.type == 'ARMATURE' and obj.data is not self)
bpy.types.Armature.rigify_rig_ui = PointerProperty(type=bpy.types.Text,
name="Rigify Target Rig UI",
- description="Defines the UI to overwrite. If unset, 'rig_ui.py' will be used")
+ description="Defines the UI to overwrite. If unset, a new one will be created and named based on the name of the rig")
bpy.types.Armature.rigify_finalize_script = PointerProperty(type=bpy.types.Text,
name="Finalize Script",
diff --git a/rigify/generate.py b/rigify/generate.py
index d63399cc..8a2aa942 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -65,7 +65,9 @@ class Generator(base_generate.BaseGenerator):
target_rig = meta_data.rigify_target_rig
if not target_rig:
- if "metarig" in self.metarig.name:
+ if meta_data.rigify_rig_basename:
+ rig_new_name = meta_data.rigify_rig_basename
+ elif "metarig" in self.metarig.name:
rig_new_name = self.metarig.name.replace("metarig", "rig")
elif "META" in self.metarig.name:
rig_new_name = self.metarig.name.replace("META", "RIG")
diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py
index b98907ee..d581805f 100644
--- a/rigify/rig_ui_template.py
+++ b/rigify/rig_ui_template.py
@@ -1159,7 +1159,8 @@ class ScriptGenerator(base_generate.GeneratorPlugin):
if script:
script.clear()
else:
- script = bpy.data.texts.new("rig_ui.py")
+ script_name = self.generator.obj.name + "_ui.py"
+ script = bpy.data.texts.new(script_name)
metarig.data.rigify_rig_ui = script
for s in OrderedDict.fromkeys(self.ui_imports):
diff --git a/rigify/ui.py b/rigify/ui.py
index 68cfd330..3a7af546 100644
--- a/rigify/ui.py
+++ b/rigify/ui.py
@@ -137,10 +137,16 @@ class DATA_PT_rigify_advanced(bpy.types.Panel):
armature_id_store = context.object.data
col = layout.column()
+
+ row = col.row()
+ row.active = not armature_id_store.rigify_target_rig
+ row.prop(armature_id_store, "rigify_rig_basename", text="Rig Name")
+
+ col.separator()
col.row().prop(armature_id_store, "rigify_target_rig", text="Target Rig")
col.row().prop(armature_id_store, "rigify_rig_ui", text="Rig UI Script")
- col.separator()
col.row().prop(armature_id_store, "rigify_widgets_collection")
+ col.separator()
col.row().prop(armature_id_store, "rigify_force_widget_update")
col.row().prop(armature_id_store, "rigify_mirror_widgets")
col.separator()