Jump to content


This topic is now archived and is closed to further replies.


Script To Remove Keys? & Auto Place Nulls In Joint Skeleton

Recommended Posts

Hi Everyone,

I've recently been doing some work with BVH files...Constraining an IK rigs controllers using CDTools(but could do the same with mocca) to nulls placed in the hierarchy of a BVH skeleton,this involves quite a bit of 'prep' of the BVH files. Here are the BVH files i'm using...its a massive and free resource.....the frame rate of some of files seems a little slow and i've managed to fix that using motion clips .

Heres my workflow/pipeline so far for prepping the BVH files.

First find an approx scale factor in the bvh import settings,then:

1 - Deleting 'extra' or unnecessary position keys on all bones except the root bone(normally Hips).

2 - Deleting repeated unchanging rotation keys from certain specified bones.

3 - Deleting 'site' objects and certain specified bones,such as fingers or thumbs that i don't need.

Basically getting rid of anything at all that i don't need...this helps when it comes to using motion clips as things start to get very slow in the viewport even working with just the bones

4 - Positioning the Root Bone(Hips) of the BVH skeleton at the same position as the root joint of my IK rig/Default T-pose,this is a little difficult as i can only move the null object(skeleton) that contains the BVH bone skeleton - i can't change the position keys on the BVH root bone.The only way i found so far is to do it by eye,especially as the start position for the BVH root bone relative to its parent null varies from file to file.

5 - Transfer the position+scale of all the BVH bones(EXCEPT the root bone) to the pos and Z-axis scale of my Default T-pose - not really sure about this

6 - Place a pre positioned set of nulls(my Constraint Targets for the IK controls) into the BVH skeleton-by this i mean make them a child of specified bones NOT change their position or rotation

Once the BVH skeleton has been 'doctored' i've then been making them into motion clips,making changes to the speed and blending clips together...save the motion clip and apply it to my 'Default T-pose' or bake it back to keys and let the constraints on the IK rig do their thing.

This is all great,but 'prepping' the BVH files is very time consuming....so eventually i get to the question :) :

Steps 1->3 Bearing in mind that the BVH skeleton hierarchy is the same for all the files and i would be wanting to remove the same keys and objects from any of the files....can this be scripted and how?

Step 6 Each Target null would have its own parent bone and these would be same across any of the files....can this be scripted and again how? ...although they can't be made a child of the bone until steps 4 and 5 have been completed

Cheers for any help on this....one day when i give up sleep altogether i'll find the time to work through Rui's COFFEE book that i bought ages ago...but for now i'm a COFFEE virgin


Huge thank you to Dan for his help with this so far spoton.gif

ps does any of that make any sense? ohmy.gif

Share this post

Link to post

The main advantage of the files i'm using is that they are totally free and you are free to use them for what you want....It is a massive resource of all types of motions..yes the frame rate is out but as i said above thats a simple fix with motion clips and i can blend the motions as well.

simplify?!! sorry but your site is a total mess...when i did find the demo button it tells me to click on a skull that downloads a zip file with a empty folder in it asking me to send an email requesting a free motion....which i've done and heard nothing yet.

Anyway even if i did get your files i would still have to scale them to same size as my rig and place the target nulls in the joint hierarchy for my IK controllers....i'm not just talking about creating just a MOCap rig here,i'm making a rig that can be constrained to a BVH file But also be controlled/hand animated.

Sorry but i feel that your post is simply Advertising your site and makes no real attempt to answer the questions i posed


Share this post

Link to post
Guest dataflow

this is more of a post to make sure you are doing your first steps the easier way

1-2)you can remove unused keys with the "Clean Tracks" command under the "Functions" menu (in timeline menu)

4) you can do using the "Tranfser" command under the "Functions" menu (from the main menu)

unless im misunderstanding what your doing there

Share this post

Link to post

ok well i've had a cup of tea and calmed down a bit now....

have received and checked over a couple of your files....i would still have to go through all steps i mentioned above with your files except the speed change,but this doesn't really make much difference as i'm still using NLA motion clips to mix motions(i don't want to use another piece of software to mix the moves)as characters would need to interact with the 'set' for example jump over objects or walk around them,from what i've read on the animpeeple wiki any imported objects become part of the character....so working just in cinema is better for me..

cheers and i hope someone can help me with the scripting questions i posed.


Share this post

Link to post

Cheers Data spoton.gif ,only just seen your reply...

Step1-2 ..never used the clean tracks function before,that certainly makes it faster although it does leave the first and last keys for some reason...now if i could get that into a script and it removed all the keys that would be great....what i'm hoping to do is have a script that would remove all the position keys for the specified bones,could be done by selecting those joints and then running the script,but better would be that the script scanned the selected heirarchy for bone names and removed the pos and/or rot keys for those bones that matched its 'given' list as well as removing certain objects entirely from the skeleton...

Step4...the transfer can't do it i'm afraid...i can't actually select and move the root bone(it has pos keys on it that i need to maintain) what i'm doing at the moment is moving the parent null of the skeleton (which is not usually at the same position as the root bone of these files)until the root bone lines up with the pelvis of my IK rig



Share this post

Link to post
Guest dataflow

what bone/bones do you want to delete?

and try to explain in steps other things you want it to do

ill try making a script.

im just a noob at coffee so it will be more of an exercise for me (so no guarantees)

Share this post

Link to post

Hi Data,Thanks for the offer spoton.gif I did a bit of reading up and fiddling with scripting late last night...didn't get too far though..this kinda thing is totally new to me..i have Rui's COFFEE book,so took a look at maybe the first 30%..i managed to get a script working that would look for specific named bones in the document and give a print out in the console if it found them,but that was about it,Also found on Per Anders site or was it on a SDK wiki? a script that randomly selected child objects...although i couldn't get it too select 'named' bones....i need to get a better grasp of the basics i think mf_bookread.gif

Anyway here is what i want the script to do:

Step1:DELETE from the OM the following objects:

-ALL objects named "Site" -these are null objects i don't need

-ALL objects named "LeftFingerBase" + "LFingers" + "LThumb" -these are bones i don't need

-ALL objects named "RightFingerBase" + "RFingers" + "RThumb" -these are bones i don't need

Step2: DELETE from the Timeline ALL POSITION Keys on the following objects:

- "LHipJoint" "LeftUpLeg" "LeftLeg" "LeftFoot" "LeftToeBase"

- "RHipJoint" "RightUpLeg" "RightLeg" "RightFoot" "RightToeBase"

- "LowerBack" "Spine" "Spine1" "Neck" "Neck1" "Head"

- "LeftShoulder" "LeftArm" "LeftForeArm" "LeftHand"

- "RightShoulder" "RightArm" "RightForeArm" "RightHand"

This is every object in the document with the exception of the Top Parent Null called "Skeleton" AND most Important the Root Bone Called "Hips"

So maybe its quicker/easier to delete Position Keys from ALL objects in Doc. EXCEPT "Skeleton" and "Hips" ?

Step3: DELETE from the Timeline ALL ROTATION Keys on the following objects:

- "LHipJoint" "RHipJoint" "LeftShoulder" "RightShoulder"

All the above Steps combined into one script if possible would make for quicker workflow.

In my first post i mentioned moving the Top Parent Null "Skeleton" until the Root Bone "Hips" was in the same Position and as the Root Bone of my Default T-pose,then scale at rotate to match as well.

Then positioning,rotating and scaling along the Z-axis the child bones so they are the same length and in the same position as their counterparts in the Default T-pose

I've no idea if this is possible with scripting and is beyond anything i can imagine...to start with i don't know if a script could move a parent null until its first child object was in the same position as a Defined object...maybe by it calculating the position "offset" between the Parent null and the child and then using this to match the position to the position of the defined object....but seems to me like something that might end in nasty never ending loop...The child bones would have to be "transferred" one at a time down the hierarchy ....I'm not really sure about this whole section,but it does give me the exact same T-pose at Frame1 for all the BVH Skeletons

So in short probably best ignore that,and i do it manually.


This step(script) would be run after i've sorted out the above mess of lining up the T-pose,this places my Constraint Targets(for the IK controls) into the BVH Skeleton Hierarchy

Now this maybe a tricky one for you to do as the way i'm thinking of doing it,is by using the CDTools LinkObject Command....and i don't think you have CDTools although you could maybe test it in demo mode with a demo copy of R11..?

When using the CDLinkObject Command,you first select the object you want to be a Child then Ctrl click on the object you want to be the Parent and then run the command,hey presto! you Child object is inside your Parent object....So i would need the script to select the specified Child object THEN add to that selection? the specified Parent object and run the CDLinkObject command.

Here is the list of objects i need 'parented up' The first object is the Child(TargetNull) second is the Parent(Bone).

- "BodyControlTarget" -> "Hips"

- "HipControlTarget" -> "Hips"

- "ChestControlTarget" -> "Neck"

- "HeadControlTarget" -> "Neck1"

- "LShoulderControlTarget" -> "LeftShoulder"

- "LElbowControlTarget" -> "LeftShoulder"

- "LArmControlTarget" -> "LeftHand"

- "RShoulderControlTarget" -> "RightShoulder"

- "RElbowControlTarget" -> "RightShoulder"

- "RArmControlTarget" -> "RightHand"

- "LFootControlTarget" -> "LeftFoot"

- "RFootControlTarget" -> "RightFoot"

I may add some other targets to this for the foot setup as the BVHskeleton contains a Toe Bone i'd like to use,but i need to play about and get the IKgoal and Target objects sorted out for that first....don't think it would be hard for me to add that later to a script anyway....Now this 'Parenting' maybe possible without using the CDLink Command...there maybe a similar command in cinema that i don't know...so possibly that could be better way to go.

My Control Targets need to maintain their current PSR...this script would only be moving them in Hierarchy.

So there it is,sounds so easy when its written down...NOT!



Sorry Mods,for the very long post

Share this post

Link to post
Guest dataflow

i also got to where you got to.

i can get it to find the object.

now just need to get it to delete it :)

Share this post

Link to post

Cool sc018.gif looks like we're both starting from the same point then

I'll get a bit of time to look into this tomorrow i hope...breaking it down into small bits will hopefully make it easier to compose a full script



Share this post

Link to post

Hi Data..a quick heads up...I've found another method for all of this..that doesn't really need a script to place nulls in the BVH Skeleton...May still need to make a script to remove some Objects from the BVHSkeleton and remove keys from certain bones(Steps 1,2&3) although this is just to speed up certain parts of the workflow.

Will post later with details..

Cheers for your help,


Share this post

Link to post
This topic is now closed to further replies.

  • Recently Browsing   0 members

    No registered users viewing this page.

Latest Topics

Latest Comments

  • Create New...