Samples/HUD/HUDTextElement.py

Samples/HUD/HUDTextElement.py
1 # Copyright 2011 Autodesk, Inc. All rights reserved.
2 # Use of this software is subject to the terms of the Autodesk license agreement
3 # provided at the time of installation or download, or which otherwise accompanies
4 # this software in either electronic or hard copy form.
5 #
6 # Script description:
7 # Creates a FBHUDTextElement at center of screen and retrieves a list of
8 # supported Fonts. Also attempts to set it to "Times New Roman"; if this
9 # is not available in the system, MotionBuilder will fall back on one of
10 # "Arial", "Helvetica", "Sans", or "FreeSans", whichever found first.
11 # If all these are not available, the first in the supported Font list will
12 # be used.
13 #
14 # Topic: FBHUD, FBHUDTextElement
15 #
16 from pyfbsdk import *
17 
18 #Init
19 Scene = FBSystem().Scene
20 System = FBSystem()
21 Application = FBApplication()
22 
23 #Create HUD with Text Element
24 Application.FileNew()
25 
26 HUD = FBHUD("MyHUD")
27 lText = FBHUDTextElement("Text1")
28 Scene.ConnectSrc(HUD) #Connect the HUD to the scene
29 lText.Content = "Pineapple"
30 lText.X = 0
31 lText.Y = 0
32 lText.Scale = 2
33 lText.Justification = FBHUDElementHAlignment.kFBHUDCenter
34 lText.HorizontalDock = FBHUDElementHAlignment.kFBHUDCenter
35 lText.VerticalDock = FBHUDElementVAlignment.kFBHUDVCenter
36 
37 #Get and print list of supported Fonts
38 for ind in lText.GetFontList():
39  print ind
40 
41 lText.Font = "Times New Roman" #Set Font of FBHUDTextElement
42 
43 HUD.ConnectSrc(lText) #Connect HUDTextElement to the HUD
44 Scene.Cameras[0].ConnectSrc(HUD) #Connect to Perspective camera