-- ************************************************** -- Provide Moho with the name of this script object -- ************************************************** ScriptName = "MR_SelectChildBones" -- ************************************************** -- General information about this script -- ************************************************** MR_SelectChildBones = {} function MR_SelectChildBones:Name() return self:Localize('UILabel') end function MR_SelectChildBones:Version() return '1.0' end function MR_SelectChildBones:UILabel() return self:Localize('UILabel') end function MR_SelectChildBones:Creator() return 'Eugene Babich' end function MR_SelectChildBones:Description() return self:Localize('Description') end -- ************************************************** -- Is Relevant / Is Enabled -- ************************************************** function MR_SelectChildBones:IsRelevant(moho) local skel = moho:Skeleton() if skel == nil then return false end return true end function MR_SelectChildBones:IsEnabled(moho) return true end -- ************************************************** -- The guts of this script -- ************************************************** function MR_SelectChildBones:Run(moho) local skel = moho:Skeleton() if not skel then return end local selectedBones = 0 for i = 0, skel:CountBones()-1 do local bone = skel:Bone(i) if bone.fSelected and not bone.fShy and not bone.fHidden then selectedBones = selectedBones + 1 end end local newSelectedBones = 0 for i = 0, skel:CountBones()-1 do local bone = skel:Bone(i) if not bone.fHidden and skel:IsAncestorSelected(i) then bone.fSelected = true end end moho:UpdateSelectedChannels() moho.layer:UpdateCurFrame() moho:UpdateUI() for i = 0, skel:CountBones()-1 do local bone = skel:Bone(i) if bone.fSelected and not bone.fShy and not bone.fHidden then newSelectedBones = newSelectedBones + 1 end end if selectedBones == newSelectedBones then local targetBonesList = {} for i = 0, skel:CountBones() - 1 do local bone = skel:Bone(i) if bone.fSelected then for b = 0, skel:CountBones() - 1 do local isTargetFound = false local targetBoneCandidat = skel:Bone(b) if targetBoneCandidat.fParent == -1 then if bone.fTargetBone.value == b then isTargetFound = true end if isTargetFound then local isBoneNotInList = true for k, tBone in pairs(targetBonesList) do if tBone == targetBoneCandidat then isBoneNotInList = false break end end if isBoneNotInList then table.insert(targetBonesList, targetBoneCandidat) break end end end end end end for k, tBone in pairs(targetBonesList) do tBone.fSelected = true end moho.layer:UpdateCurFrame() moho:UpdateSelectedChannels() moho:UpdateUI() end end -- ************************************************** -- Localization -- ************************************************** function MR_SelectChildBones:Localize(text) local phrase = {} phrase['Description'] = 'This script allows you to select the child bones of the selected bones. If you run it twice, it will also select the targets of the selected bones, if they exist.' phrase['UILabel'] = 'MR Select Child Bones '..self:Version() return phrase[text] end
MR Select Child Bones
Listed
Author: eugenebabich
View Script
Script type: Button/Menu
Uploaded: Aug 18 2024, 10:09
Script Version: 1.0
This script allows you to select the child bones of the selected bones.
If you run it twice, it will also select the targets of the selected bones, if they exist.
This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 280
MR Select Child Bones
Listed
Author: eugenebabich
View Script
Script type: Button/Menu
Uploaded: Aug 18 2024, 10:09
Script Version: 1.0
This script allows you to select the child bones of the selected bones.
If you run it twice, it will also select the targets of the selected bones, if they exist.
This script, and all other scripts on this site are distributed as free software under the GNU General Public License 3.0 or later.
Downloads count: 280