---------------
Edit:
Basically I need to check if a bone is keyed in a specific smartbone action. That's the basic question.
----------------
So I'm working on an old script to smooth interpolate switches with bone rotation and got it working pretty good.
I would like this to work with smartbone actions but can't quite figure out how to find the smartbone that controls everything and use that key.
Here is how my script works.
You give a bone and switch layer the same name. The script matches them up and adds and deletes keys for the switch based on each angle KEY FRAME of the bone. works great. Works with bone constraints as well using fAngleControlParent to find keys.
For example:
A switch layer and a bone are both named "Phonemes".
Add an angle key on the bone and the switch gets keyed.
Delete the key on the bone and the switch key is deleted.
Lets mix it up a bit...
Remove all the keys.
Add an angle control bone called "Control". Add an angle control to the "Phonemes" bone.
The "Phonemes" bone now HAS NO KEYS and is controlled via constraint by the "Control" bone.
No problems! Works great! I just look for the fAngleControlParent of the "Phonemes" bone and use THOSE keys to key the switch layer.
Here's where I'm stuck.
I added a third bone called "SmartBone".
The bone called "Control" is only rotated in the "Smartbone" action.
The only bone with a keyframe now is "SmartBone".
The bone "Control" has no keys in the main timeline only in the smart bone action.
The bone "Phonemes" has no keys and neither does its fAngleControlParent so can't look there for keys.
I need to follow up this convoluted chain from the original "Phonemes" bone to it's fAngleControlParent, "Control" then continue up to the bone called "SmartBone" and use that key to key the switch layer.
Phew! good lord. I get dizzy thinking about it too hard.
I understand a bunch of the new scripting commands for actions, layer:HasAction for the layer and the bones etc. I just haven't figured out how to get there from the bone and switch layers with matching names. I need to go from a bone with no keys and a constraint, up to the fAngleControlParent which ALSO has no keys except in the "SmartBone" bones action. There's a gap in the path I can't figure out how to get across.
Check if bone is keyed in an action?
Moderators: Víctor Paredes, Belgarath, slowtiger
- synthsin75
- Posts: 10253
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Check if bone is keyed in an action?
See the first code example here: https://mohoscripting.com/methods/mohol ... boneaction
It counts through the bones and checks a specific bone animation channel for if it has an action and if it's for a smart bone.
It counts through the bones and checks a specific bone animation channel for if it has an action and if it's for a smart bone.
- 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/
Re: Check if bone is keyed in an action?
Yes I have been playing around with all of the references in those scripts for actions with layers and bones with no useable results yet.
All my results are inconsistent and kind of sort of random or just weird.
I have a very simple file with 1 bone layer, 4 bones, and 2 switch layers.
(ignoring the switch layers to try and figure out how actions and scripting work.)
1 bone has a smartbone. This is the ONLY action and only ONE other bone keyed in that action besides the actual smartbone.
My results are very odd and a bit frustrating.
I am doing a basic bone loop and counting the bones' actions via and printing info to the console.
The results returned are identical for ALL the bones. They all SEEM to have the same number of actions. All the bones have or are a part of the smartbone action on each loop.
I fully admit user error is a viable option. I've been fiddling for hours and can't get clear results that make sense based on what's in the Moho file.
Here's the basic loop I'm using for testing:
All of the print() lines print identical info for all the bones with no variation.
I get 1.0 for the number of actions (2). 2 actions makes sense if the main timeline counts as an action? But all the bones shouldn't have 2 actions. Only one or possibly 2 bones should be part of smartbone.
Like I said this is very likely user error of some kind but I may have to abandon the search for a solution.
All my results are inconsistent and kind of sort of random or just weird.
I have a very simple file with 1 bone layer, 4 bones, and 2 switch layers.
(ignoring the switch layers to try and figure out how actions and scripting work.)
1 bone has a smartbone. This is the ONLY action and only ONE other bone keyed in that action besides the actual smartbone.
My results are very odd and a bit frustrating.
I am doing a basic bone loop and counting the bones' actions via
Code: Select all
bone.fAnimAngle:CountActions()
The results returned are identical for ALL the bones. They all SEEM to have the same number of actions. All the bones have or are a part of the smartbone action on each loop.
I fully admit user error is a viable option. I've been fiddling for hours and can't get clear results that make sense based on what's in the Moho file.
Here's the basic loop I'm using for testing:
Code: Select all
for i = 0, boneCount - 1 do
local bone = skel:Bone(i)
local theBoneName = bone:Name()
print(theBoneName.." - how many actions: "..bone.fAnimPos:CountActions())
for act=0, bone.fAnimAngle:CountActions()-1 do -- this SHOULD only count actions for fAnimAngle for the current bone?
print(theBoneName.." - action number: "..act) -- prints the bone name and the loop number for action count
local actName = bone.fAnimPos:ActionName(act) -- the action name
local isSmartBone = moho.layer:IsSmartBoneAction(actName) -- true or false for if the bone has or is part of smartboneaction?
if isSmartBone then
print(theBoneName.." - Smart Bone Action - "..actName) -- prints the bone name and action name-- same for ALL BONES
end
end
end
I get 1.0 for the number of actions (2). 2 actions makes sense if the main timeline counts as an action? But all the bones shouldn't have 2 actions. Only one or possibly 2 bones should be part of smartbone.
Like I said this is very likely user error of some kind but I may have to abandon the search for a solution.
Re: Check if bone is keyed in an action?
Wooohooo! I think it was... er... uh... user error. I'm now getting the results expected... mainly because I'm an idiot.
Yep, user error <sigh>. In the code above for my test loop I was checking for actions on fAnimPos instead of fAnimAngle!!!!!
I WAS CHECKING THE WRONG FRACKING CHANNEL FOR ACTIONS! What a maroon!
You could hear my sigh of relief all over the world. I'm sooooo freaking happy now.
Onward and upward.
EDIT: Holy cow works GREAT NOW! I can add keys to switch layers for smooth interpolation USING FREAKING SMART BONES!!!! YEEEEHAAAAA!
I was so close to giving up.
Yep, user error <sigh>. In the code above for my test loop I was checking for actions on fAnimPos instead of fAnimAngle!!!!!
I WAS CHECKING THE WRONG FRACKING CHANNEL FOR ACTIONS! What a maroon!
You could hear my sigh of relief all over the world. I'm sooooo freaking happy now.

Onward and upward.
EDIT: Holy cow works GREAT NOW! I can add keys to switch layers for smooth interpolation USING FREAKING SMART BONES!!!! YEEEEHAAAAA!
I was so close to giving up.
- synthsin75
- Posts: 10253
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Check if bone is keyed in an action?
I didn't have time to go over your code, but glad to hear you got it sorted out.
It's always frustrating when a simple mistake holds up progress.
It's always frustrating when a simple mistake holds up progress.
- 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/