From 289455148f8d19544b108758cbc65307805ec58b Mon Sep 17 00:00:00 2001 From: pullusb Date: Wed, 23 Jul 2025 12:15:50 +0200 Subject: [PATCH] Fix error for blender 4 and above using bone collection system 2.0.0 - fixed: bone collection instead of layers for Blender 4+ --- CHANGELOG.md | 4 ++++ __init__.py | 4 ++-- fn.py | 22 ++++++++++------------ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a56f561..b628f9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +2.0.0 + +- fixed: bone collection instead of layers for Blender 4+ + 1.8.1 - added: bone propertie search and active bone picker diff --git a/__init__.py b/__init__.py index 17034bd..9a035a4 100644 --- a/__init__.py +++ b/__init__.py @@ -4,8 +4,8 @@ bl_info = { "name": "Auto Walk", "description": "Develop a walk/run cycles along a curve and pin feets", "author": "Samuel Bernou", - "version": (1, 8, 1), - "blender": (3, 0, 0), + "version": (2, 0, 0), + "blender": (4, 0, 0), "location": "View3D", "warning": "", "doc_url": "https://gitlab.com/autour-de-minuit/blender/auto_walk", diff --git a/fn.py b/fn.py index bdf4be3..78d63ef 100644 --- a/fn.py +++ b/fn.py @@ -9,11 +9,7 @@ def get_addon_prefs(): function to read current addon preferences properties access with : get_addon_prefs().super_special_option ''' - import os - addon_name = os.path.splitext(__name__)[0] - preferences = bpy.context.preferences - addon_prefs = preferences.addons[addon_name].preferences - return (addon_prefs) + return bpy.context.preferences.addons[__package__].preferences def open_addon_prefs(): '''Open addon prefs windows with focus on current addon''' @@ -739,14 +735,15 @@ def go_edit_mode(ob, context=None): def get_visible_bones(ob): - '''Get name of all editable bones (unhided *and* on a visible bone layer''' - # visible bone layer index - visible_layers_indexes = [i for i, l in enumerate(ob.data.layers) if l] - # check if layers overlaps + '''Get name of all editable bones (unhidden *and* on a visible bone layer)''' + + ## list names + visible_bones_collection = [c.name for c in ob.data.collections_all if c.is_visible] + + ## check if layers overlaps visible_bones = [b for b in ob.data.bones \ - if not b.hide \ - if any(i for i, l in enumerate(b.layers) if l and i in visible_layers_indexes)] - + if not b.hide and any((col.name in visible_bones_collection for col in b.collections))] # is in a visible bone collection + return visible_bones @@ -760,6 +757,7 @@ def get_x_pos_of_visible_keys(ob, act): ## skip offset + fcu related to invisible bones viz_bones = get_visible_bones(ob) + print('viz_bones: ', viz_bones) visible_bone_names = [b.name for b in viz_bones] keys = []