-- *************************************************** -- General information about this script -- *************************************************** ScriptName = "GE_Bones_for_Shapes" -- *************************************************** -- General information about this script -- *************************************************** GE_Bones_for_Shapes = {} function GE_Bones_for_Shapes:Name() return "Bones for Shapes" end function GE_Bones_for_Shapes:Version() return "0.1" end function GE_Bones_for_Shapes:Description() return "Create a set of bones reasy for shape sort script" end function GE_Bones_for_Shapes:Creator() return "Genete" end function GE_Bones_for_Shapes:UILabel() return "GE: Create Bones for Shapes" end function GE_Bones_for_Shapes:IsEnabled(moho) if(moho:ParentSkeleton() ~= nil and moho:CountShapes()>0) then return true else return false end end -- *************************************************** -- The guts of this script -- *************************************************** function GE_Bones_for_Shapes:Run(moho) local skel = moho:ParentSkeleton() local mesh = moho:Mesh() if (skel == nil or mesh == nil) then print ("Please run the script inside a Vector layer being it a child of a Bone layer") return end local cshapes = mesh:CountShapes() if (cshapes == 0) then print ("There must be almost one shape") return end local bones = skel:CountBones() if (bones == 0) then print ("There must be almost one bone") return end local selected = -1 for k=0, bones-1 do if (skel:Bone(k).fSelected == true) then selected = k break end end if (selected == -1) then print ("Almost one bone must be selected") return end moho.document:PrepUndo(moho.layer:Parent()) moho.document:SetDirty() for i=0, cshapes -1 do local bone = skel:AddBone(0) local v = LM.Vector2:new_local() v:Set(0.01*i,-0.05*(i+1)) bone.fParent = selected bone:SetName( i .. ".sh") bone.fAnimPos:SetValue(0, v) bone.fAnimAngle:SetValue(0,0.0) bone.fLength = 0.05 bone.fStrength = 0 end end