Samples/HUD/HUDTextElement.py
 
 
 
Samples/HUD/HUDTextElement.py
# Copyright 2011 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:
# Creates a FBHUDTextElement at center of screen and retrieves a list of 
# supported Fonts. Also attempts to set it to "Times New Roman"; if this
# is not available in the system, MotionBuilder will fall back on one of
# "Arial", "Helvetica", "Sans", or "FreeSans", whichever found first.
# If all these are not available, the first in the supported Font list will
# be used.
#
# Topic: FBHUD, FBHUDTextElement
#
from pyfbsdk import *

#Init
Scene = FBSystem().Scene
System = FBSystem()
Application = FBApplication()

#Create HUD with Text Element
Application.FileNew()

HUD = FBHUD("MyHUD")
lText = FBHUDTextElement("Text1")
Scene.ConnectSrc(HUD)          #Connect the HUD to the scene
lText.Content =  "Pineapple"
lText.X = 0
lText.Y = 0
lText.Scale = 2
lText.Justification = FBHUDElementHAlignment.kFBHUDCenter
lText.HorizontalDock = FBHUDElementHAlignment.kFBHUDCenter
lText.VerticalDock = FBHUDElementVAlignment.kFBHUDVCenter

#Get and print list of supported Fonts
for ind in lText.GetFontList():
    print ind
    
lText.Font = "Times New Roman"   #Set Font of FBHUDTextElement
    
HUD.ConnectSrc(lText) #Connect HUDTextElement to the HUD
Scene.Cameras[0].ConnectSrc(HUD) #Connect to Perspective camera