Page 1 of 1

Modify the "select Bone layer" plugin

Posted: Mon Jul 01, 2024 10:51 am
by peng

Code: Select all

-- **************************************************
-- 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.4'
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)
  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
this is a plugin that allows to use shortcut to select bone layer https://mohoscripts.com/script/am_select_bonelayer. Just want to know if anyone knows how to modify that allows the same function to select "transform bone" tool at the same time.

thank you very much.

Re: Modify the "select Bone layer" plugin

Posted: Mon Jul 01, 2024 11:29 am
by SimplSam
From what I know, you cannot select or change the active tool using a Moho script.

The only alternative is to use an external tool like AutoHotkey, Stream Deck, Python to send key-command sequences to Moho.

Re: Modify the "select Bone layer" plugin

Posted: Sat Jul 13, 2024 3:27 am
by 570295535
You can modify this file: C:\Program Files\Moho 14\Resources\Support\Scripts\Tool\_tool_list.txt
Adjust the order of lm_transform-bone to the first position to achieve it.
Change it to this:

Code: Select all

group MOHO.Localize("/Tools/Group/Bone=Bone")
tool	lm_transform_bone	...
tool	lm_select_bone		...
tool	lm_add_bone			...
tool	lm_manipulate_bones	...

Re: Modify the "select Bone layer" plugin

Posted: Sat Jul 13, 2024 7:44 am
by SimplSam
Interesting approach, but I don't think that will consistently choose the Transform Bone tool. It will depend on what tool you are in previously (i.e. Transform Layer etc. will affect this).

You should not need to edit _tool_list. If you need to change the order of Tools, you can do so via Preferences:

Image

Also .. an alternate approach to this would be changing to the bone group, when you select the Bone tool. i.e. mod the tool to also select the bone layer. This approach was recently discussed/implemented for the Mr Pose tool: viewtopic.php?p=219548#p219548 (though it may currently have some drawbacks)