The FBPlug class is the base class of FBComponent and FBProperty. The FBPlug class is responsible for managing the connections among components and properties. There are two types of connections:
Component-Property connections define the state and behavior of a component through its properties. A component owns a list of properties, as described in FBProperty - Object Properties. The following figure describes the owned/owner relationship between an FBComponent and its FBProperty.
The FBProperty "p" is owned by the FBComponent "c". It is accessed via FBPlug.GetOwned().
# Assume that FBProperty p is indexed at 0. p = c.GetOwned(0)
The FBComponent "c" is the owner of FBProperty "p". It is accessed via FBPlug.GetOwner().
# An FBProperty can only have one owner, so there is no index required. c = p.GetOwner()
Component-Component connections allow for components to be organized in a parent-child hierarchy. Such a hierarchy is present in the scene graph organization (see Scene Elements). The following figure describes the source/destination relationship between two instances of FBComponent.
The FBComponent "child" is the source of the FBComponent "parent". It is accessible via FBPlug.GetSrc().
# Assume that FBComponent child is indexed at 0. child = parent.GetSrc(0)
The FBComponent "parent" is the destination of the FBComponent "child". It is accessible via FBPlug.GetDst().
# Assume that FBComponent parent is indexed at 0. parent = child.GetDst(0)
The diagram below illustrates the source-destination relationships among components, and the owned-owner relationships among components and properties.
Accessing the source components of c0.
# Assume c1 is indexed at 0. c1 = c0.GetSrc(0) # Assume c2 is indexed at 1. c2 = c0.GetSrc(1)
Accessing the owned property of c0.
p0 = c0.GetOwned(0)
Accessing the destination component of c2.
c0 = c2.GetDst(0)
Accessing the property p4 from property p1.
# A property can only have one owner. c1 = p1.GetOwner() # Assume c0 is indexed at 0. c0 = c1.GetDst(0) # Assume c2 is indexed at 1. c2 = c0.GetSrc(1) # Assume p4 is indexed at 2. p4 = c2.GetOwned(2)
Click on a model in the scene to select it, and run the program below. It will output all the connections of the selected FBModel in the scene.
from pyfbsdk import * ############################################################### # Helper Function(s). # ############################################################### # Print the class and object name of the FBPlug. def printPlug(pPlug): try: print pPlug.ClassName() + ": " + pPlug.LongName except: pass # Print the sources of the plug. def printSources(pPlug): print "Source Components: " print "-----------------------" numSrc = pPlug.GetSrcCount() for i in range(0, numSrc): printPlug(pPlug.GetSrc(i)) print "" # Print the destinations of the plug. def printDestinations(pPlug): print "Destination Components: " print "-----------------------" numDst = pPlug.GetDstCount() for i in range(0, numDst): printPlug(pPlug.GetDst(i)) print "" # Print the owned properties of the component. def printOwned(pPlug): print "Owned Properties: " print "-----------------------" numOwned = pPlug.GetOwnedCount() for i in range(0, numOwned): printPlug(pPlug.GetOwned(i)) print "" # Print the owner of the property. def printOwner(pPlug): print "Owner Component: " print "-----------------------" printPlug(pPlug.GetOwner()) # Inspect the plug. def inspectConnections(pPlug): print "Plug inspected: " + pPlug.LongName + ' (' + pPlug.ClassName() + ')\n' printSources(pPlug) printDestinations(pPlug) printOwned(pPlug) printOwner(pPlug) ############################################################### # Main. # ############################################################### # Inspect the selected models. models = FBModelList() FBGetSelectedModels(models) for model in models: inspectConnections(model)