Right now I am sometimes saving information in the name of a bone so a tool knows how to behave. For example I will rename "B1" to "B1 !s" and it will *never* be scaled and scale keysframes will always be deleted, because tools will recognize the "!s" tag in the name. There's a few other things I'm already saving in bone names, but it's not ideal.
Could I somehow create my own bone values such as fIgnoredByIK and store a boolean there?
I know you can just do "bone.constrainScale = true", but it will not be remembered after saving and re-opening a document. And saving the info as layerdata isn't great either because it will get lost when you copy paste bones etc.
It's probably not possible, but sometimes you guys seem to open magic doors to realms I never knew could exist
Is there a way to save information into a bone?
Moderators: Víctor Paredes, Belgarath, slowtiger
- hayasidist
- Posts: 3556
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Is there a way to save information into a bone?
We have script data at the layer level.
(begin whine)
I have wanted (and asked for!) metadata at the "item" level since I don't know when. Bones, shapes are top of my list. I can live without it at point level.
(end whine)
It's a simple exercise to create (say) a JSON-style list of {"Bones to Ignore" = ["B1", B2",...]} and save it in the layer's script data.
The big challenge is keeping that list consistent with reality given that, the bone name can be changed in Moho in a variety of ways. BUT: if you're already "as happy as you can be" with being "sensible" about naming / re-naming / deleting /... bones then this could be a way to go -- you might need a "companion tool" to keep the scriptdata up to date. (https://mohoscripting.com/methods/1122)
(begin whine)
I have wanted (and asked for!) metadata at the "item" level since I don't know when. Bones, shapes are top of my list. I can live without it at point level.
(end whine)
It's a simple exercise to create (say) a JSON-style list of {"Bones to Ignore" = ["B1", B2",...]} and save it in the layer's script data.
The big challenge is keeping that list consistent with reality given that, the bone name can be changed in Moho in a variety of ways. BUT: if you're already "as happy as you can be" with being "sensible" about naming / re-naming / deleting /... bones then this could be a way to go -- you might need a "companion tool" to keep the scriptdata up to date. (https://mohoscripting.com/methods/1122)
- synthsin75
- Posts: 10007
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Is there a way to save information into a bone?
Technically you can use any AnimVal channel to at least store booleans, as 1 and 0. The trick is to do it in the negative timeline and set the key to step...so it doesn't calculate anything prior to frame zero.
The drawback of doing this is that those keyframes don't exist in action timelines, but that may not be a problem in your case.
The drawback of doing this is that those keyframes don't exist in action timelines, but that may not be a problem in your case.
- 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: Is there a way to save information into a bone?
Myeah, I considered this, but the risk of data getting lost is too big. I want others to be able to copy/paste bones from rig to rig without having to worry about losing the data.hayasidist wrote: ↑Tue Jul 12, 2022 1:01 pmWe have script data at the layer level. [...] The big challenge is keeping that list consistent with reality given that, the bone name can be changed in Moho in a variety of ways.
Interesting idea! Clear animation doesn't delete them, so that's good. But I'd need to use a channel that we never use, so I can always hide it from the timeline. Motorspeed, perhaps... I might actually try to store everything in a created action though. That might work, and seems copy-pastable per bone. Will give this a shot.synthsin75 wrote: ↑Wed Jul 13, 2022 12:06 am Technically you can use any AnimVal channel to at least store booleans, as 1 and 0. The trick is to do it in the negative timeline and set the key to step...so it doesn't calculate anything prior to frame zero.
The drawback of doing this is that those keyframes don't exist in action timelines, but that may not be a problem in your case.
+1000hayasidist wrote: ↑Tue Jul 12, 2022 1:01 pm (begin whine)
I have wanted (and asked for!) metadata at the "item" level since I don't know when. Bones, shapes are top of my list. I can live without it at point level.
(end whine)
I once requested :Tags() and :SetTags() for bones, but custom bonedata would be just as good and maybe better.
Re: Is there a way to save information into a bone?
So far this works extremely well for disabling certain channels for specific bones. Thanks for the idea Wes!Lukas wrote: ↑Thu Jul 14, 2022 9:56 amInteresting idea! Clear animation doesn't delete them, so that's good. But I'd need to use a channel that we never use, so I can always hide it from the timeline. Motorspeed, perhaps... I might actually try to store everything in a created action though. That might work, and seems copy-pastable per bone. Will give this a shot.
I need to clean up the code but here's the idea:
Code: Select all
LK_ConstrainBone.ConstrainDataActionName = "FO_BoneData"
-- **************************************************
-- Set Constraint
-- **************************************************
function LK_ConstrainBone:SetConstraint(channel, value, axis) -- * For example: (bone.fAnimPos, true)
local checkFrame = self:CheckFrame(axis) -- * axis can be: nil / "x" / "y" / "z"
channel:ActivateAction(self.ConstrainDataActionName)
if value then
local vec2 = LM.Vector2:new_local()
channel:SetValue(checkFrame, vec2)
else
channel:DeleteKey(checkFrame)
end
channel:ActivateAction("")
end
-- **************************************************
-- Get Constraint
-- **************************************************
function LK_ConstrainBone:Constraint(channel, axis)
local checkFrame = self:CheckFrame(axis)
channel:ActivateAction(self.ConstrainDataActionName)
local keyed = channel:HasKey(checkFrame)
channel:ActivateAction("")
return keyed
end
-- **************************************************
-- Get frame for Constraint Data
-- **************************************************
function LK_ConstrainBone:CheckFrame(axis)
local checkFrame = 1
if axis == "x" then
checkFrame = 2
elseif axis == "y" then
checkFrame = 3
elseif axis == "z" then
checkFrame = 4
end
return checkFrame
end
- synthsin75
- Posts: 10007
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Is there a way to save information into a bone?
I have a script, in development hell, that I use fColorStrength to assign unique IDs to points.
I also keyframe them at -1000042 so it doesn't conflict with my delete negative keyframes script.
I also keyframe them at -1000042 so it doesn't conflict with my delete negative keyframes script.
- 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/
- hayasidist
- Posts: 3556
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Is there a way to save information into a bone?
all very interesting ideas! I have not (yet!) used the V12 "Action" additions to channels ...