macroScript exchangeBonesTool category:"3dgill_Tools" tooltip:"Exchange Bones Tool" buttonText:"exchange" ( rcMenu exchangeBonesInstructions ( submenu "Instructions" ( menuItem exchUseWhenLine1 "Use this script when skinned " menuItem exchUseWhenLine2 "vertices have incorrect bones " menuItem exchUseWhenLine3 "controlling them. " menuItem exchBlankLine1 " " menuItem exchStep1Line1 "1- With the modifier tab open," menuItem exchStep1Line2 " select the skinned mesh and " menuItem exchStep1Line3 " turn on envelope mode in it's" menuItem exchStep1Line4 " skin modifier. " menuItem exchBlankLine2 " " menuItem exchStep2Line1 "2- Select the skinned vertices" menuItem exchStep2Line2 " that need to switch bones. " menuItem exchBlankLine3 " " menuItem exchStep3Line1 "3- Select the incorrect bone " menuItem exchStep3Line2 " within the skin modifier or " menuItem exchStep3Line3 " the Weight Tool and press the" menuItem exchStep3Line4 " 'Wrong Bone Here' button. " menuItem exchBlankLine4 " " menuItem exchStep4Line1 "4- Select the correct bone " menuItem exchStep4Line2 " within the skin modifier or " menuItem exchStep4Line3 " the Weight Tool and press the" menuItem exchStep4Line4 " 'Right Bone Here' button. " menuItem exchBlankLine5 " " menuItem exchStep5Line1 "5- Press Apply to exchange " menuItem exchStep5Line2 " bones. " ) ) rollout exchangeBonesRollout "Exchange Bones" ( label wrongBoneLabel "Wrong Bone:" offset:[-15,3] across:2 button wrongBoneInfo "Wrong Bone Here" width:110 offset:[-10,0] label rightBoneLabel "Right Bone:" offset:[-15,3] across:2 button rightBoneInfo "Right Bone Here" width:110 offset:[-14,0] button exchangeBoneExecute "Apply" width:184 on wrongBoneInfo pressed do ( global wrongBoneNum = skinOps.getSelectedBone $.modifiers[#Skin] wrongBoneInfo.text = skinOps.getBoneName $.modifiers[#Skin] wrongBoneNum 0 ) on rightBoneInfo pressed do ( global rightBoneNum = skinOps.getSelectedBone $.modifiers[#Skin] rightBoneInfo.text = skinOps.getBoneName $.modifiers[#Skin] rightBoneNum 0 ) on exchangeBoneExecute pressed do ( selysno = 0 numInfluence = 0 bonenum = 0 correctVertexWeight = 0.0 totalverts = skinOps.getNumberVertices $.modifiers[#Skin] for selvert = 1 to totalverts do ( selysno = skinOps.isVertexSelected $.modifiers[#Skin] selvert if selysno == 1 do ( numInfluence = skinOps.getVertexWeightCount $.modifiers[#Skin] selvert for influysno = 1 to numInfluence do ( bonenum = skinOps.getVertexWeightBoneID $.modifiers[#Skin] selvert influysno if bonenum == wrongBoneNum do ( correctVertexWeight = (skinOps.getVertexWeight $.modifiers[#Skin] selvert influysno) skinOps.setVertexWeights $.modifiers[#Skin] selvert wrongBoneNum 0 skinOps.setVertexWeights $.modifiers[#Skin] selvert rightBoneNum correctVertexWeight ) ) ) ) ) ) createDialog exchangeBonesRollout width:200 height:83 menu:exchangeBonesInstructions )