From 7cbbb1f7006e375d858cc6e905f89062b0d7ef7c Mon Sep 17 00:00:00 2001 From: Ingenoire Date: Thu, 1 Aug 2024 15:26:46 +0200 Subject: [PATCH] Update vrm_bakin_addon.py --- vrm_bakin_addon.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vrm_bakin_addon.py b/vrm_bakin_addon.py index 5ac4fb0..e7c82cb 100644 --- a/vrm_bakin_addon.py +++ b/vrm_bakin_addon.py @@ -19,9 +19,7 @@ class AddItemHooksButton(bpy.types.Operator): bl_label = "Add Item Hooks" bl_description = "Adds Item Hook bones to the left and right hand of the VRM model. This will let you hold items in either hand using the 'Attach Model to Cast' event in Bakin." - def execute(self, context): - # Your script for adding item hooks goes here # Push the current state to the undo stack bpy.ops.ed.undo_push(message="Run VRM Bakin Utils") @@ -45,8 +43,11 @@ def execute(self, context): hand_bone = bpy.data.armatures['Armature'].edit_bones[hand_bone_name] hand_bone.select = True + # Determine the new bone name + new_bone_name = 'L_itemhook' if 'L_' in hand_bone_name else 'R_itemhook' + # Add a new bone called itemhook at the same position as the hand bone - new_bone = bpy.data.armatures['Armature'].edit_bones.new(f'{hand_bone_name[:7]}_itemhook') + new_bone = bpy.data.armatures['Armature'].edit_bones.new(new_bone_name) offset = mathutils.Vector((0.06, 0.04, -0.02)) if 'L_' in hand_bone_name else mathutils.Vector((-0.06, 0.04, -0.02)) new_bone.head = hand_bone.head + offset new_bone.tail = hand_bone.head + mathutils.Vector((hand_bone.tail.y - hand_bone.head.y, -hand_bone.tail.x + hand_bone.head.x, 0)) + offset if 'L_' in hand_bone_name else hand_bone.head + mathutils.Vector((hand_bone.tail.y - hand_bone.head.y, hand_bone.tail.x - hand_bone.head.x, 0)) + offset