# Copyright 2009 Autodesk, Inc.  All rights reserved.
# Use of this software is subject to the terms of the Autodesk license agreement 
# provided at the time of installation or download, or which otherwise accompanies
# this software in either electronic or hard copy form.
#
# Script description:
# Will plot story tracks NOT selected that are assigned to a character.
#
# Topic: FBStory, FBStoryTrack, FBCharacter, FBPlotOptions
#

from pyfbsdk import *

lStory = FBStory()
lScene = FBSystem().Scene
lcharactersList = lScene.Characters


# Set options for Plot process

lOptions = FBPlotOptions()

lOptions.ConstantKeyReducerKeepOneKey = True
lOptions.PlotAllTakes = False
lOptions.PlotOnFrame = True
lOptions.PlotPeriod = FBTime( 0, 0, 0, 1 )
lOptions.PlotTranslationOnRootOnly = True
lOptions.PreciseTimeDiscontinuities = True
lOptions.RotationFilterToApply = FBRotationFilter.kFBRotationFilterGimbleKiller
lOptions.UseConstantKeyReducer = True


for lTracks in lStory.RootFolder.Tracks:
    if lTracks.Selected == False:
        lCharacterIdx = lTracks.CharacterIndex
        lCharacter = lcharactersList[lCharacterIdx - 1]
        lCharacter.PlotAnimation (FBCharacterPlotWhere.kFBCharacterPlotOnSkeleton,lOptions )
        lTracks.Mute = True


for lFolders in lStory.RootFolder.Childs:
    for lTracks in lFolders.Tracks:
        if lTracks.Selected == False:
            lCharacterIdx = lTracks.CharacterIndex
            lCharacter = lcharactersList[lCharacterIdx - 1]
            lCharacter.PlotAnimation (FBCharacterPlotWhere.kFBCharacterPlotOnSkeleton,lOptions )
            lTracks.Mute = True