Darkstorm - Pipeline/Scripting

I've gotten to the stage on this project where some really basic placeholder animations need to be exported so the programmers can get a head start setting up the pawn in UDK. The process for exporting animation was


  1. Merge the reference into the scene 
  2. Bake the animation on to the skeleton 
  3. Delete the control rig 
  4. Export all using a custom preset.
    So I created a simple script, because small time wins add up!
    $boneList = `ls -typ joint`;
    select $boneList;
    bakeResults -simulation true -t (`playbackOptions -q -min` + ":" + `playbackOptions -q -max`) -hierarchy below -sampleBy 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -removeBakedAttributeFromLayer false -bakeOnOverrideLayer false -minimizeRotation true -at "tx" -at "ty" -at "tz" -at "rx" -at "ry" -at "rz";
    select -all;
    duplicate -rr -un;
    loadUnloadReference(0, 0);
    select -r ctrl_MasterControl;
    Delete;
    Export;
    A quick breakdown of the script.
    1. List then select all the bones.
    2. Bake Animation with the time set to the max and min of the time range (only on the translate and rotates)
    3. Select all the objects in the scene.
    4. Duplicate all the objects which converts them from referenced objects into scene objects
    5. Unload all the references
    6. Select the Nurb Master controller
    7. Delete the controller
    8. Open the export dialog.
    1 Click Animation Exporting.

    The hardest parts of making this was baking the animation based on the to the scenes current timeline and unloading the reference.

    When using the command bakeResults you have to set a -t (time) attribute with the start and end frame listed. I read on autodesks site that it is possible to set time to -t ":" for it to specify all keys but mel spits back an error saying it must be set, after a quick search I found someone else had created a similar bake animation script and his work around was using the playbackOptions -min and -max functions which works!

    The other problem that popped up was trying to remove the reference from the scene without using names, I quickly found that
    file -removeReference "Guard_Rig.ma";
    Would remove a reference if you used the files name and that
    file -unloadReference Guard_RigRN;
    Would unload the reference if you used the namespace. 
    But as there are a few different characters I needed to find a way to remove any reference, after right clicking and removing a reference from the Outliner I found that the script editor was using the command loadUnloadRefence(0, 0) so I used that and it works!

    The only things I would do to this script right now is create a proc for it, something like.