Files
KKBP_Importer/extras/updatebones.py
小煜 5d9e09e9c3 feat: Add KoikatsuBlenderPipeline addon with import/export functionality
- Add core addon files (__init__.py, KKPanel.py, preferences.py, common.py)
- Add import pipeline with armature, mesh, and material modification modules
- Add export pipeline with material baking and FBX preparation utilities
- Add material combiner tool for texture atlas generation and optimization
- Add extras utilities for animation, rigging, and asset management
- Add bone orientation data from better_fbx for accurate skeletal structure
- Add comprehensive documentation and wiki with multi-language support (EN, JP, ZH)
- Add animation library retargeting lists for ARP and Rokoko motion capture
- Add Rigify integration scripts for advanced rigging workflows
- Add shader file (KK Shader V8.0.blend) for material rendering
- Add manifest and license files for addon distribution
- Add changelog documenting version history and improvements
- Initialize complete Blender addon project for Koikatsu character import/export
2025-12-06 15:26:19 +08:00

35 lines
1.5 KiB
Python

import bpy
from ..interface.dictionary_en import t
from .. import common as c
class update_bones(bpy.types.Operator):
bl_idname = "kkbp.updatebones"
bl_label = "Update bones"
bl_description = t('bone_visibility_tt')
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
arm = c.get_rig() if c.get_rig() else c.get_armature()
arm = bpy.data.armatures[arm.data.name]
#check if the outfit linked to accessory bones on the armature is visible or not, then update the bone visibility
for bone in arm.bones:
if bone.get('id'):
hide_this_bone = True
for outfit_number in bone['id']:
matching_outfit = bpy.data.objects.get('Outfit ' + outfit_number + ' ' + c.get_name())
if matching_outfit:
print(matching_outfit.users_collection[0].name)
#also check if the collection this outfit belongs to is enabled in the viewlayer
outfit_collection = c.get_layer_collection_state(matching_outfit.users_collection[0].name)
if not outfit_collection and not matching_outfit.hide_get():
print("Enabling bone {} for outfit {}".format(bone.name, bone['id']))
hide_this_bone = False
break
bone.hide = hide_this_bone
return {'FINISHED'}
if __name__ == "__main__":
bpy.utils.register_class(update_bones)