Page 1 of 1

How can I quickly select a bone for the selected child-bone ?

Posted: Mon Jan 10, 2022 8:31 am
by suizenji
For complex hairstyles, is there any way to quickly select the bones at the ends of the hair after selecting the Bone at the root of the hair?
https://d.kuku.lu/d7ebc234f
Of course, I am aware of the existence of Bone Selection Buttons, a useful script that registers bones for use.
I want to quickly select a child's bones without registering the bones.

Re: How can I quickly select a bone for the selected child-bone ?

Posted: Mon Jan 10, 2022 4:55 pm
by synthsin75

Code: Select all

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

ScriptName = "Syn_SelChildBones"

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

Syn_SelChildBones = {}

function Syn_SelChildBones:Name()
	return "Select Child Bones"
end

function Syn_SelChildBones:Version()
	return "0.1"
end

function Syn_SelChildBones:Description()
	return "Select Child Bones"
end

function Syn_SelChildBones:Creator()
	return "©2022 J.Wesley Fowler (SynthSin75)"
end

function Syn_SelChildBones:UILabel()
	return "SYN: Select Child Bones"
end


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

function Syn_SelChildBones:IsEnabled(moho)
	if (moho:Skeleton()) then
		return true
	end
	return false
end

function Syn_SelChildBones:Run(moho)

	moho.document:PrepUndo(moho.layer)
	moho.document:SetDirty()
	
	local skel = moho:Skeleton()	
	local childBones = {}
	for i=0, skel:CountBones()-1 do
		local bone = skel:Bone(i)
		if (skel:IsAncestorSelected(i)) then
			table.insert(childBones, bone)
		end
	end
	skel:SelectNone()
	for i,v in pairs(childBones) do
		v.fSelected = true
	end
end

Re: How can I quickly select a bone for the selected child-bone ?

Posted: Mon Jan 10, 2022 9:06 pm
by SimplSam
This is a quicker / cleaner solution than I was contemplating.

Only query (which is probably for suizenji) is whether the original selected bone/s should also remain selected. I had assumed that they would. i.e. 'Parents + Descendants' - rather than just 'Descendants'.

Re: How can I quickly select a bone for the selected child-bone ?

Posted: Mon Jan 10, 2022 9:15 pm
by synthsin75
Yeah, the picture does seem to leave the first one selected. So this small change will do that:

Code: Select all

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

ScriptName = "Syn_SelChildBones"

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

Syn_SelChildBones = {}

function Syn_SelChildBones:Name()
	return "Select Child Bones"
end

function Syn_SelChildBones:Version()
	return "0.1"
end

function Syn_SelChildBones:Description()
	return "Select Child Bones"
end

function Syn_SelChildBones:Creator()
	return "©2022 J.Wesley Fowler (SynthSin75)"
end

function Syn_SelChildBones:UILabel()
	return "SYN: Select Child Bones"
end


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

function Syn_SelChildBones:IsEnabled(moho)
	if (moho:Skeleton()) then
		return true
	end
	return false
end

function Syn_SelChildBones:Run(moho)

	moho.document:PrepUndo(moho.layer)
	moho.document:SetDirty()
	
	local skel = moho:Skeleton()	
	local childBones = {}
	for i=0, skel:CountBones()-1 do
		local bone = skel:Bone(i)
		if (skel:IsAncestorSelected(i)) then
			table.insert(childBones, bone)
		end
	end
	--skel:SelectNone()
	for i,v in pairs(childBones) do
		v.fSelected = true
	end
end

Re: How can I quickly select a bone for the selected child-bone ?

Posted: Sat Jan 15, 2022 2:48 pm
by suizenji
Thank you very much.
It was truly a parent + child selection.
This script is very, very easy to use.
Thank you for your great script. Thank you very much. :) :) :) :) :) :) :) :)