Motion Builder Python Tpose problem

Hello,
I’m currently new to Motion Builder 2020. I’m writing a script that loads a characterize from an xml file on to a existing character that has animation baked to bones. This character has an old definition that needs to be updated. All was going well until I wanted to use character.SetCharacterizeOn(True) within a function. It worked ok when I ran each line of code individually before merging all into a function.

Below is my function (update_characterize) . If I dont include SetCharacterizeOn() within that function but run each line of code below individually, it will work. If I run all three lines of code at once it will fail. The failing is not being able to save the Tpose in the character definition even when the character is in its Tpose when the script has ran. If you set the source to stance (after the script has ran) the pose will match the first frame of animation . It seems to ignore the Tpose when turning on characterize.

update_characterize(“Joe_blogs”, “NameOfMyCharacterDefinitionFile”)

current_char = FBApplication().CurrentCharacter

current_char.SetCharacterizeOn(True)# Arg True sets to biped

#--------------------------------------------------------------------------------------------------------------

I have a function (below set_tpose() ) for my Tpose that is added within update_characterize(). I believe I have written this code correctly?

def set_tpose(character):
“”"

Description: Set Character to Tpose using FBCharacter

Arg: Character = FBCharacter

"""
# Set TPose
if character!=None:
    character.GoToStancePose(True, True)
else:
    FBMessageBox("Character","There is no current Character in the scene", "Ok")

I can show the rest of the code if requested.

Thanks

Steve

I have found the solution. It appears I need to run FBEvaluate() to update Motion Builder with my characterize edits before turning on characterize. Below shows this example
# Turn characterize on!
FBSystem().Scene.Evaluate()
current_char.SetCharacterizeOn(True)# Arg True sets to biped