From 8cb8ccbee02df871db7cec15530f76046c695b15 Mon Sep 17 00:00:00 2001 From: schroef Date: Tue, 8 Oct 2024 17:12:14 -0400 Subject: [PATCH] update to bl 4.0 Fixed layers converted to bone collections --- CHANGELOG.md | 8 ++++++- README.md | 9 ++++---- __init__.py | 65 +++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1fe03e..fc7daf3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,15 @@ # Changelog All notable changes to this project will be documented in this file. +## [0.1.1] - 2024-10-08 +### Fix +- Make it work in bl4.0+ + Update to bone collections + ## [0.0.9] - 2020-11-30 ### Fix - Save custom folder button > label missed text="" - ## [0.0.8] - 2020-06-03 ### Fix - Rig layers set selection code @@ -52,6 +56,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +[0.1.1]:https://github.com/schroef/Rigify-Save-Presets/releases/tag/v0.1.1 +[0.1.0]:https://github.com/schroef/Rigify-Save-Presets/releases/tag/v0.1.0 [0.0.9]:https://github.com/schroef/Rigify-Save-Presets/releases/tag/v0.0.9 [0.0.8]:https://github.com/schroef/Rigify-Save-Presets/releases/tag/v0.0.8 [0.0.7]:https://github.com/schroef/Rigify-Save-Presets/releases/tag/v0.0.7 diff --git a/README.md b/README.md index fbfff87..0a2719d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This addon makes it possible to save rig setup to a preset folder. The function The added presets can then be loaded directly using the add menu. To get the new preset to show, you need to either restart blender or reload the all the addons pressing F8. Its also now possible save Rigify main settings as presets. These can be loaded at any time, no need for a refresh. -!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/Rigify-Save-Presets/images/rigify-save-presets-v009.png?v20241007) +!['Example Rig Presets'](https://raw.githubusercontent.com/wiki/schroef/Rigify-Save-Presets/images/rigify-save-presets-v011.png?v20241008) ## Rigify Addon @@ -17,15 +17,15 @@ It is important to note that Rigify only automates the creation of the rig contr !['Example Rigify Metarig'](https://raw.githubusercontent.com/wiki/schroef/Rigify-Save-Presets/images/Addon_Rigify_0.5_split_metarig.png?v20241007) ->Addon documentation can be found at: [Rigify Addon Extention page](https://archive.blender.org/wiki/2015/index.php/Extensions:2.6/Py/Scripts/Rigging/Rigify/) +>Addon documentation can be found at: [Rigify manual](https://docs.blender.org/manual/en/latest/addons/rigging/rigify/index.html) ### System Requirements | **OS** | **Blender** | | ------------- | ------------- | -| OSX | Blender 2.80+ | -| Windows | Not Tested | +| OSX | Not Tested | +| Windows | Blender 4.0+ | | Linux | Not Tested | @@ -40,6 +40,7 @@ It is important to note that Rigify only automates the creation of the rig contr 7. Activate the checkbox for the plugin that you will now find in the list. >this addon requires Rigify to be active +>Older 2.80 - 3.6.0 version can be found in this branch: [Rigify-Save-Presets bl2.80-bl3.60](https://github.com/schroef/Rigify-Save-Presets/tree/bl-280) >Older 2.79 version can be found in this branch: [Rigify-Save-Presets bl2.79](https://github.com/schroef/Rigify-Save-Presets/tree/bl-279) diff --git a/__init__.py b/__init__.py index d97bf71..e812235 100644 --- a/__init__.py +++ b/__init__.py @@ -8,9 +8,9 @@ bl_info = { "name": "Rigify Save Presets", - "version": (0, 0, 9), + "version": (0, 1, 1), "author": "Rombout Versluijs", - "blender": (2, 80, 0), + "blender": (4, 0, 0), "description": "Makes is easier to save rig presets to Rigify folder", "location": "Armature properties, Bone properties, View3d tools panel, Armature Add menu", "wiki_url": "https://github.com/schroef/rigify-save-presets", @@ -39,8 +39,17 @@ def write_rig_settings(obj, layers=False, func_name="create", groups=False): arm = obj.data #First delete all old ones - code.append("\nbpy.ops.armature.rigify_bone_group_remove_all()") - + code.append("\narm.collections.active_index = 0") + code.append("\nfor col in arm.collections_all:") + code.append("\tbpy.ops.armature.collection_remove()\n") + + #remove all colors + + code.append("\ntry:") + code.append("\tbpy.ops.armature.rigify_color_set_remove_all()") + code.append("except:") + code.append("\tpass\n") + # Rigify bone group colors info if groups and len(arm.rigify_colors) > 0: code.append("\nfor i in range(" + str(len(arm.rigify_colors)) + "):") @@ -59,18 +68,38 @@ def write_rig_settings(obj, layers=False, func_name="create", groups=False): code.append('arm.rigify_colors[' + str(i) + '].select = ' + str(select[:])) #code.append('arm.rigify_colors[' + str(i) + '].standard_colors_lock = ' + str(standard_colors_lock)) - # Rigify layer layout info - if layers and len(arm.rigify_layers) > 0: - - for i in range(len(arm.rigify_layers)): - name = arm.rigify_layers[i].name - row = arm.rigify_layers[i].row - selset = arm.rigify_layers[i].selset - group = arm.rigify_layers[i].group - code.append('arm.rigify_layers[' + str(i) + '].name = "' + name + '"') - code.append('arm.rigify_layers[' + str(i) + '].row = ' + str(row)) - code.append('arm.rigify_layers[' + str(i) + '].selset = ' + str(selset)) - code.append('arm.rigify_layers[' + str(i) + '].group = ' + str(group)) + + # Add bone collections + code.append('\nfor i in range('+(str(len(arm.collections_all)+1))+'):') + code.append('\tbpy.ops.armature.collection_add()\n') + + if layers and len(arm.collections_all) > 0: + + for i in range(len(arm.collections_all)): + name = arm.collections_all[i].name + colorsetid = arm.collections_all[i].rigify_color_set_id + selset = arm.collections_all[i].rigify_sel_set + uirow = arm.collections_all[i].rigify_ui_row + uititle = arm.collections_all[i].rigify_ui_title + code.append('arm.collections_all[' + str(i) + '].name = "' + name + '"') + code.append('arm.collections_all[' + str(i) + '].rigify_color_set_id = ' + str(colorsetid)) + code.append('arm.collections_all[' + str(i) + '].rigify_sel_set = ' + str(selset)) + code.append('arm.collections_all[' + str(i) + '].rigify_ui_row = ' + str(uirow)) + code.append('arm.collections_all[' + str(i) + '].rigify_ui_title = "' + str(uititle)+'"') + + + # # Rigify layer layout info + # if layers and len(arm.rigify_layers) > 0: + + # for i in range(len(arm.rigify_layers)): + # name = arm.rigify_layers[i].name + # row = arm.rigify_layers[i].row + # selset = arm.rigify_layers[i].selset + # group = arm.rigify_layers[i].group + # code.append('arm.rigify_layers[' + str(i) + '].name = "' + name + '"') + # code.append('arm.rigify_layers[' + str(i) + '].row = ' + str(row)) + # code.append('arm.rigify_layers[' + str(i) + '].selset = ' + str(selset)) + # code.append('arm.rigify_layers[' + str(i) + '].group = ' + str(group)) #print(code) return "\n".join(code) @@ -134,7 +163,7 @@ def execute(self, context): target_path = os.path.join("presets", self.preset_subdir) target_path = bpy.utils.user_resource('SCRIPTS', - target_path, + path=target_path, create=True) if not target_path: @@ -388,7 +417,7 @@ def panel_func(self, context): def register(): for cls in classes: bpy.utils.register_class(cls) - bpy.types.DATA_PT_rigify_buttons.append(panel_func) + bpy.types.DATA_PT_rigify.append(panel_func) def unregister():