-- *************************************************** -- General information about this script -- *************************************************** ScriptName = "GE_Bone_of_Shape" -- *************************************************** -- General information about this script -- *************************************************** GE_Bone_of_Shape = {} function GE_Bone_of_Shape:Name() return "Bones for Shape" end function GE_Bone_of_Shape:Version() return "0.1" end function GE_Bone_of_Shape:Description() return "Select the bone correspondint to its shape." end function GE_Bone_of_Shape:Creator() return "Genete" end function GE_Bone_of_Shape:UILabel() return "Bone of Shape" end function GE_Bone_of_Shape:IsEnabled(moho) if(moho:ParentSkeleton() ~= nil and moho:Mesh() ~= nil and moho:CountSelectedShapes()>0) then return true else return false end end -- *************************************************** -- The guts of this script -- *************************************************** function GE_Bone_of_Shape:Run(moho) local skel = moho:ParentSkeleton() local mesh = moho:Mesh() if (skel == nil or mesh == nil) then return end local cshapes = mesh:CountShapes() if (cshapes == 0) then return end local bones = skel:CountBones() if (bones == 0) then return end local selected = -1 for k=0, cshapes-1 do if (mesh:Shape(k).fSelected == true) then selected = k break end end if (selected == -1) then return end moho.document:PrepUndo(moho.layer:Parent()) moho.document:SetDirty() for i=0, bones -1 do local b = skel:Bone(i) local name = b:Name() local targetname = selected .. ".sh" if (name == targetname) then skel:Bone(i).fSelected = true else skel:Bone(i).fSelected = false end end end