Help: Color bone keys in the same colors as the bones?
Moderators: Víctor Paredes, Belgarath, slowtiger
Help: Color bone keys in the same colors as the bones?
Hi everyone,
I'm looking for a way to colorize all bone keyframes in the same color as the bone label of the actual bone the key belongs to.
Either via a script that looks at all keyframes in a bone layer and colors them correctly, or by putting some code after 'moho:NewKeyframe(CHANNEL_BONE_T)' etc, that colors the keys while your making them. (Or even better, both)
I don't really know where to start so any help would be greatly appreciated.
I'm looking for a way to colorize all bone keyframes in the same color as the bone label of the actual bone the key belongs to.
Either via a script that looks at all keyframes in a bone layer and colors them correctly, or by putting some code after 'moho:NewKeyframe(CHANNEL_BONE_T)' etc, that colors the keys while your making them. (Or even better, both)
I don't really know where to start so any help would be greatly appreciated.
- synthsin75
- Posts: 9968
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Help: Color bone keys in the same colors as the bones?
I guess the separate bone color channels don't do what you want?
- 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: Help: Color bone keys in the same colors as the bones?
They do, but more often than not they are hidden to avoid timeline clutter. In some situations seeing the keys by color could really help the animators.
Re: Help: Color bone keys in the same colors as the bones?
Sounds like a cool idea.
Sometimes I use this method which helps with stuff like blinks which can clutter timelines.
It only works with stuff like this because it starts with an action.
Colour the keys in the action for ' blink'
then the blink action, when dropped into the mainline, carries the key colours. Then I know which keys are the blink bones.
The thing I really want to reduce timeline clutter is to stop translate and scale keys being laid for smart bone dials and bones that only rotate. Some targets only need translate keys.
This would mean the bone select tool could designate which channels to key.
Sometimes I use this method which helps with stuff like blinks which can clutter timelines.
It only works with stuff like this because it starts with an action.
Colour the keys in the action for ' blink'
then the blink action, when dropped into the mainline, carries the key colours. Then I know which keys are the blink bones.
The thing I really want to reduce timeline clutter is to stop translate and scale keys being laid for smart bone dials and bones that only rotate. Some targets only need translate keys.
This would mean the bone select tool could designate which channels to key.
Re: Help: Color bone keys in the same colors as the bones?
Totally agree!chucky wrote:The thing I really want to reduce timeline clutter is to stop translate and scale keys being laid for smart bone dials and bones that only rotate. Some targets only need translate keys.
This would mean the bone select tool could designate which channels to key.
I’ve actually built a tool that does just that, but it’s really tailored to our workflow/pipeline and still has some quirks/bugs/crashes. It also has a button that removes those unwanted keyframes in a project animated with the regular tools.
Regular bones (not pin-bones) with labels AND constraints are considered smartbonedials, and are only able to get rotation keys, they are impossible to translate or scale with the tool.
If a pinbone has a label it is considered a smartbonetarget, and is only translatable.
A cool bonus thing is, if you do try to translate a smartbonedial, it actually translates the hidden "GUI" bone (which all dials are parented to in our rigs), but puts the translation key at frame 1, that way dials never float all over your scene.
We're already using the tool for all bone animation in production, but it's still a work in progress and not ready for a public release. I'll see if I can release only this part of the code, because this part is not causing any crashes.
Edit: Here's a menu script that deletes those keys: http://www.lukaskrepel.nl/temp/ASP/lk_r ... n_keys.lua
...But, hopefully the official team tackles this problem with better bone constraints.
Re: Help: Color bone keys in the same colors as the bones?
I guess it's not possible. I'd need something like:
or
But no command like it seems to exist.
(Right?)
Code: Select all
AnimChannel:SetLabelColor(when, colID)
Code: Select all
AnimChannel:SetLabelColorByID(keyID, colID)
(Right?)
- synthsin75
- Posts: 9968
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Help: Color bone keys in the same colors as the bones?
Lukas wrote:I guess it's not possible. I'd need something like:orCode: Select all
AnimChannel:SetLabelColor(when, colID)
But no command like it seems to exist.Code: Select all
AnimChannel:SetLabelColorByID(keyID, colID)
(Right?)
Code: Select all
--get key color
local interp = MOHO.InterpSetting:new_local()
local ch = moho.layer.fTranslation
ch:GetKeyInterp(moho.frame, interp)
local tags = {"Plain", "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Tan", "Pink", "Torquoise", "Cadet Blue", "Coral"}
print(tags[interp.tags+1])
--set key color
interp.tags = 0 --Plain
ch:SetKeyInterp(moho.frame, interp)
I just made the "tags" table to print the color names.
- 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: Help: Color bone keys in the same colors as the bones?
D'oh. I didn't realise the color labels where accessible trough the interpolation settings for keys, this is great. Thanks a lot, again, Wes!synthsin75 wrote:Code: Select all
--get key color local interp = MOHO.InterpSetting:new_local() local ch = moho.layer.fTranslation ch:GetKeyInterp(moho.frame, interp) local tags = {"Plain", "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Tan", "Pink", "Torquoise", "Cadet Blue", "Coral"} print(tags[interp.tags+1]) --set key color interp.tags = 0 --Plain ch:SetKeyInterp(moho.frame, interp)
- synthsin75
- Posts: 9968
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Help: Color bone keys in the same colors as the bones?
Glad to help, Lukas. I was meaning to get around to writing this script, but I haven't found the time.Lukas wrote:D'oh. I didn't realise the color labels where accessible trough the interpolation settings for keys, this is great. Thanks a lot, again, Wes!
- 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: Help: Color bone keys in the same colors as the bones?
Ok, so here's a script you can run on a bone layer and it will color all bone keys according to the bone colors:
http://www.lukaskrepel.nl/temp/ASP/LK_PaintKeys.lua
You could use it as a menu script, and edit in this line in all 'onmouseup' functions (at the end of the function, before the last end) of the transform bone tool and manipulate bone tool (or whatever you're using to animate bones) and it will color keys while your setting them. (It would color all keys all the time, but it doesn't seem to slow things down at all):
Here's the whole thing:
http://www.lukaskrepel.nl/temp/ASP/LK_PaintKeys.lua
You could use it as a menu script, and edit in this line in all 'onmouseup' functions (at the end of the function, before the last end) of the transform bone tool and manipulate bone tool (or whatever you're using to animate bones) and it will color keys while your setting them. (It would color all keys all the time, but it doesn't seem to slow things down at all):
Code: Select all
LK_PaintKeys:Run(moho)
Code: Select all
ScriptName = "LK_PaintKeys"
LK_PaintKeys = {}
function LK_PaintKeys:Name()
return "Paint keys"
end
function LK_PaintKeys:Version()
return "0.01"
end
function LK_PaintKeys:IsBeginnerScript()
return false
end
function LK_PaintKeys:Description()
return ("Paint keys the same color as their corresponding bones")
end
function LK_PaintKeys:Creator()
return "Lukas Krepel, Frame Order"
end
function LK_PaintKeys:UILabel()
return ("Paint bone keyframes")
end
function LK_PaintKeys:IsEnabled(moho)
if moho.layer:IsBoneType() and moho:CountBones() > 0 then
return true
end
return false
end
function LK_PaintKeys:IsRelevant(moho)
if moho.layer:IsBoneType() then
return true
end
return false
end
function LK_PaintKeys:Run(moho)
local c, i
local doc = moho.document
local layer = moho.layer
if layer:IsBoneType() then
local boneLayer = moho:LayerAsBone(layer)
local skel = boneLayer:Skeleton()
if skel:CountBones() > 0 then
local channels = {}
for i = 0, skel:CountBones() - 1 do
bone = skel:Bone(i)
boneColor = bone:Tags()
c = 0
c = c + 1; channels[c] = skel:Bone(i).fAnimPos
c = c + 1; channels[c] = skel:Bone(i).fAnimAngle
c = c + 1; channels[c] = skel:Bone(i).fAnimScale
c = c + 1; channels[c] = skel:Bone(i).fAnimParent
c = c + 1; channels[c] = skel:Bone(i).fTargetBone
c = c + 1; channels[c] = skel:Bone(i).fFlipH
c = c + 1; channels[c] = skel:Bone(i).fFlipV
c = c + 1; channels[c] = skel:Bone(i).fIKGlobalAngle
c = c + 1; channels[c] = skel:Bone(i).fIKLock
c = c + 1; channels[c] = skel:Bone(i).fIKParentTarget
c = c + 1; channels[c] = skel:Bone(i).fPhysicsMotorSpeed
for c = 1, #channels do
channel = channels[c]
local endKey = channel:Duration()
local thisKey = 0
local keyCount = channel:CountKeys()
local keysFound = 0
local frameNum = endKey
while keysFound < keyCount do
thisKey = channel:GetClosestKeyID(frameNum)
keyFrameNum = channel:GetKeyWhen(thisKey)
keysFound = 1 + keysFound
local interp = MOHO.InterpSetting:new_local()
channel:GetKeyInterp(keyFrameNum, interp)
interp.tags = boneColor
channel:SetKeyInterp(keyFrameNum, interp)
frameNum = keyFrameNum - 1
end
end
end
end
end
end