Page 1 of 1

Script to only copy keyframed bones?

Posted: Tue May 16, 2006 7:35 pm
by heyvern
I often find it annoying that when I copy and paste bone key frames it always pastes a keyframe for ALL bones regardless of wether that bone had a key on the frame it was copied from.

I often have to go in and select bones and delete unwanted key frames.

Or... I have to select the specific bones I want keyed and copy/paste only the selected key frame channel.

Would there be a way to create a copy key frame "tool" or script that would only paste keys for bones that HAD a key from the spot copied?

This would... well... quite frankly.. to be blunt... this would kick arse. I would cry... really... I would tear up. It would be like that scene in Titanic when Jack drowns... or when ET dies... or when Arnold lowers himself into the molten metal in T2...

-Vern

Posted: Tue May 16, 2006 9:36 pm
by Tha Narie
I'm not very familiar with all the options in Moho itself (never made an animation or drawed anything), but if there is a property that indicates if a bone on a frame has a keyframelock, it will be very easy (as extra options in my copy/paste bone script).

There are 3 properties that I haven't tested yet:
fIKLock (AnimBool)
the bone's IK lock animation channel
fIKParentTarget (AnimVec2)
the bone's IK target animation channel
fIKGlobalAngle (AnimVal)
the bone's IK angle animation channel

I guess that the fIKLock is the 'keyframe' indicator.
For the other 3 i have no clue :P

I will post an update tomorrow :)

Posted: Tue May 16, 2006 9:48 pm
by heyvern
fIKlock would refer to the "lock bone" option when you select a bone. It has nothing to do with key frames. Although all of these things would be part of a key frame.

Locking a bone prevents it from moving and forces bones in the IK chain above it to "compensate" by rotating. There is a tutorial that demonstrates this. I don't use it much as it is kind of... wonky. It works if you are patient and don't push it too far.

All of the IK items would refer to the "IK chain"... the parenting relationship of bones.

For instance I would make a guess that the fIKGlobalAngle (AnimVal) would refer to the fact that a bone can rotate on two differnt origins.. the base of the bone itself... and it rotates based on its parent which is a completely differnt point in the space... this is just a guess.

-------

From the little I have learned you can check if a bone has a key frame... so what I would be looking for seems simple to me (I've been wrong before about this).

When copying a keyframe... and then pasting... only paste keyframes that existed on bones from the copied key frame. It would seem that this would be loop through the bone list on copy... creating an array of only the bones with a key frame... then when pasting only set keys for the bones that match the list...

I may look at this myself... but I won't have time for awhile... programming requires me to not be "creative" in the traditional artistic sense... and I get "withdrawal" symptoms... please forgive the pun. ;)

-Vern

Posted: Tue May 16, 2006 10:49 pm
by Tha Narie
heyvern wrote:From the little I have learned you can check if a bone has a key frame...
Could you tell me, because I can't find it :)

Posted: Wed May 17, 2006 8:58 am
by rylleman
Tha Narie wrote:Could you tell me, because I can't find it :)
Create a loop that goes through the bones and all the frames like;

if xxx:HasKey(frame) then

Posted: Wed May 17, 2006 9:44 am
by Tha Narie
There is no HasKey(frame) method for the M_Bone class in the Moho Scripting Reference. Is it undocumented, or do I have to look somewhere else? :)

Posted: Wed May 17, 2006 10:06 am
by rylleman
Tha Narie wrote:There is no HasKey(frame) method for the M_Bone class in the Moho Scripting Reference. Is it undocumented, or do I have to look somewhere else? :)
I don't know really, I got a feeling that there are a lot stuff that are not documented in the scripting reference.
Try it, it hopefully it works...

Posted: Wed May 17, 2006 11:23 am
by heyvern
Oops!

I too thought this was a given. I just assumed you could easily check if a bone had a key.

Oh well... I will have to watch Titanic again...

-Vern