Skip to content

Commit

Permalink
update to bl 4.0
Browse files Browse the repository at this point in the history
Fixed layers converted to bone collections
  • Loading branch information
schroef committed Oct 8, 2024
1 parent 44d86c9 commit 8cb8ccb
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 23 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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).
<!--### Official Rigify Info-->

[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
Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: <b>[Rigify Addon Extention page](https://archive.blender.org/wiki/2015/index.php/Extensions:2.6/Py/Scripts/Rigging/Rigify/)</b>
>Addon documentation can be found at: <b>[Rigify manual](https://docs.blender.org/manual/en/latest/addons/rigging/rigify/index.html)</b>

### System Requirements

| **OS** | **Blender** |
| ------------- | ------------- |
| OSX | Blender 2.80+ |
| Windows | Not Tested |
| OSX | Not Tested |
| Windows | Blender 4.0+ |
| Linux | Not Tested |


Expand All @@ -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 <b>Rigify</b> to be active
>Older 2.80 - 3.6.0 version can be found in this branch: <b>[Rigify-Save-Presets bl2.80-bl3.60](https://github.com/schroef/Rigify-Save-Presets/tree/bl-280)</b>
>Older 2.79 version can be found in this branch: <b>[Rigify-Save-Presets bl2.79](https://github.com/schroef/Rigify-Save-Presets/tree/bl-279)</b>

Expand Down
65 changes: 47 additions & 18 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)) + "):")
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 8cb8ccb

Please sign in to comment.