Page 1 of 1

SelectedBoneID() return value?

Posted: Thu Mar 17, 2016 5:30 pm
by lehtiniemi
Documentation says SelectedBoneID() returns the ID of the selected bone. What does this mean? Isn't it possible to select multiple bones? Is the return value some array?

Re: SelectedBoneID() return value?

Posted: Thu Mar 17, 2016 6:00 pm
by synthsin75
This returns the first (lowest) selected bone ID. Looking at the select and transform bone tools, it seems to be a quick way to get bone names and settings to display in tool option texts, where only one can be shown, even if more are selected. It's also a quick way to check that any bones are selected, before running the code to count through all bones. If there's no selected bones, there may be no need to waste processing counting through them.

Re: SelectedBoneID() return value?

Posted: Thu Mar 17, 2016 6:01 pm
by lehtiniemi
synthsin75 wrote:This returns the first (lowest) selected bone ID. Looking at the select and transform bone tools, it seems to be a quick way to get bone names and settings to display in tool option texts, where only one can be shown, even if more are selected. It's also a quick way to check that any bones are selected, before running the code to count through all bones. If there's no selected bones, there may be no need to waste processing counting through them.
Ah, great! Thanks for a quick answer. I just wrote my own function to detect if there are bones selected, I'll replace it now :D

Re: SelectedBoneID() return value?

Posted: Thu Mar 17, 2016 6:04 pm
by synthsin75
moho:CountSelectedBones(bool) would also work just to find if any are selected, but I'm not sure what the scope of that is. Maybe layer and parent layer?

Re: SelectedBoneID() return value?

Posted: Thu Mar 17, 2016 6:06 pm
by lehtiniemi
synthsin75 wrote:moho:CountSelectedBones(bool) would also work just to find if any are selected, but I'm not sure what the scope of that is. Maybe layer and parent layer?
Thanks again. I don't know how I missed this, I was looking for it earlier. I'll go with this one!

Re: SelectedBoneID() return value?

Posted: Fri Mar 18, 2016 4:13 am
by hayasidist
you also have the fSelected field such as

Code: Select all

	for j = 0, skel:CountBones()-1 do
		if skel:Bone(j).fSelected then ...
that works on the active layer.

if you want to work on the whole doc the you'll need an outer loop to check all the layers

Code: Select all


	for i = 0, moho.document:CountLayers()-1 do	
		if moho.document:Layer(i):LayerType() = MOHO.LT_BONE then ...