The state and behavior of an FBComponent
is controlled by its list of properties (FBProperty
). To obtain an FBComponent
's list of FBProperty
instances, you may (1): consult the SDK's class reference documentation, or (2): iterate through the FBComponent.PropertyList
to print the names of the component's properties:
for property in lComponent.PropertyList:
# The following name can be used to obtain a property in FBComponent.PropertyList.Find(<name>)
print property.Name
Observe that an FBModel
uses instances of FBProperty
to define the local translation, rotation and scaling vectors. Properties can be accessed in two ways:
Directly from the FBComponent
.
In the following code sample, we obtain the local translation vector of a newly created cube.
cube = FBModelCube('myCube')
# Obtain the translation vector from the cube.
translationVector = cube.Translation
From the FBComponent
's property list (FBComponent.PropertyList
).
In the following code sample, we first obtain the translation property of a newly created cube. The actual translation vector is contained within the FBProperty
object, accessible via FBProperty.Data
.
cube = FBModelCube('myCube')
# Obtain the translation property from the cube.
translationProperty = cube.PropertyList.Find('Translation')
# Obtain the translation vector from the property object.
translationVector = translationProperty.Data
FBProperty
are generally named to reflect the return type of FBProperty.Data
. For example, FBPropertyInt.Data
returns an integer (int
) type, whereas FBPropertyVector3d.Data
returns an FBVector3d
object.An animatable property is an instance of FBPropertyAnimatable
. Many properties are animatable, such as FBModel.Translation
, and FBMaterial.Diffuse
. Before these properties can be animated however, they must have their animated status set to True
via FBPropertyAnimatable.SetAnimated()
. The following example enables the animation of a light's intensity property. For an example on how to animate a camera using key frames and animation nodes (FBAnimationNode
), see
!!CONVERSION WARNING!! broken xref detectd, likely a cross-book reference. The target GUID file is GUID-3D242E6C-0A04-4BE3-84A7-C7FF923527EE.htm#SECTION_0247889C7FDB468FB6D34A0873672FAF and the target link text is FBCamera - Cameras
.
from pyfbsdk import *
###############################################################
# Main. #
###############################################################
light = FBLight('myLight')
print 'light.Intensity animation node: ' + str(light.Intensity.GetAnimationNode())
# Enable animation for the light's intensity.
# (!) This initializes the animation node for intensity.
light.Intensity.SetAnimated(True)
print 'light.Intensity animation node: ' + str(light.Intensity.GetAnimationNode())
###############################################################
# Output. #
###############################################################
'''
light.Intensity animation node: None
light.Intensity animation node: <pyfbsdk.FBAnimationNode object at 0x000000002F588828>
'''
By calling FBComponent.PropertyList
, we are actually accessing the component's FBPropertyManager
. Each instance of FBComponent
has its own FBPropertyManager
, which contains a list of FBProperty
.
An FBProperty
may be added or removed from the component using FBComponent.PropertyAdd()
and FBComponent.PropertyRemove()
. The index returned by FBComponent.PropertyAdd()
refers to the property's position in the FBPropertyManager
. Additional instances of FBProperty
can be created within the FBComponent
using FBComponent.PropertyCreate()
.
FBComponent
and FBProperty
can also be viewed through the use of connections. For more information, see FBPlug - Object Connection Management.