-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "AM_SelectBonelayer"

-- **************************************************
-- General information about this script
-- **************************************************

AM_SelectBonelayer = {}

function AM_SelectBonelayer:Name()
	return 'Select Bonelayer'
end

function AM_SelectBonelayer:Version()
	return '1.3'
end

function AM_SelectBonelayer:UILabel()
	return 'Select Bonelayer'
end

function AM_SelectBonelayer:Creator()
	return 'Aleksei Maletin'
end

function AM_SelectBonelayer:Description()
	return 'Select Bonelayer'
end


-- **************************************************
-- Is Relevant / Is Enabled
-- **************************************************

function AM_SelectBonelayer:IsRelevant(moho)
	local hasParent = moho.layer:Parent()
	if hasParent then
		return true 
	end
	return false
end

function AM_SelectBonelayer:IsEnabled(moho)
	if moho.layer:LayerType() ~= MOHO.LT_BONE then
		return true
	end
end

-- **************************************************
-- The guts of this script
-- **************************************************

function AM_SelectBonelayer:Run(moho)
	moho.document:PrepUndo(nil)
	
	local layerToSearchForBoneParent = moho.layer
  local layerParentBone = layerToSearchForBoneParent:ControllingBoneLayer()
	if layerParentBone then
    moho:SetSelLayer(layerParentBone)
    else
    repeat
      local parent = layerToSearchForBoneParent:Parent()
      if parent then
        if parent:LayerType() == MOHO.LT_BONE then
          moho:SetSelLayer(parent)
          moho:ShowLayerInLayersPalette(parent)
          break
        else
          layerToSearchForBoneParent = parent
        end
      end	
    until not parent
  end
  end

Icon
Select Bonelayer
Listed

Script type: Button/Menu

Uploaded: Dec 08 2021, 00:53

Last modified: Dec 27 2021, 05:59

Select parent bone layer
Use this button for select parent bone layer

Installation Options:

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: 66