SelectedBoneID() return value?
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
SelectedBoneID() return value?
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?
- synthsin75
- Posts: 9968
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: SelectedBoneID() return value?
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.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: SelectedBoneID() return value?
Ah, great! Thanks for a quick answer. I just wrote my own function to detect if there are bones selected, I'll replace it nowsynthsin75 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.
- synthsin75
- Posts: 9968
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: SelectedBoneID() return value?
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?
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: SelectedBoneID() return value?
Thanks again. I don't know how I missed this, I was looking for it earlier. I'll go with this one!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?
- hayasidist
- Posts: 3514
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: SelectedBoneID() return value?
you also have the fSelected field such as
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 j = 0, skel:CountBones()-1 do
if skel:Bone(j).fSelected then ...
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 ...