Through my years at Autodesk/Alias, I have done a lot of teaching and education (some is recorded and some is not), but some things you might catch me saying during training are… “Now you get the handle to the object”, or “this now returns the handle to the object”, but what the heck does that really mean? I will know try to explain my colloquialism below using MotionBuilder Python SDK code as an example.
A Handle in Programming Terms
What I mean by a handle is what the constructor of a class returns when you create an object.
For example:
from pyfbsdk import *
lModel = FBModelCube("Kristine")
Here lModel is the "handle" to the FBModelCube object instance/copy. In this specific case you have your class definition of FBModelCube which would has been originally created by the MotionBuilder developers (we only let you create copies of this class, so you do not mess with the original version).
Once you have a "handle" to the object you want to have in your scene/file, you can use the class functions and attributes on your new copy to manipulate your copy.
The concept "handle" is more of a visual naming convention than anything else, think of it like a door handle to hold onto the copy/instance of your FBModelCube object so that you can work with it.
See this will still create an object:
FBModelCube("Kristine")
But since you didn’t assign a variable to hold the handle to your object you would not be able to access it for further manipulation.
But if you choose to use a function from the instance of the copy such as GetSelectedPointsCount (), like this:
pointCount = lModel.GetSelectedPointCount()
pointCount is not a handle to the instance, it is just an integer holding the SelectedPointCount, where lModel is the handle to the object.
Just to clarify, handles can only be created when you create an instance of the class in the Python Reference Guide, such as FBModelCube. The documentation called these ‘constructors’.
This concept is applicable to any object oriented programming language, this would fall into MotionBuilder SDK, Maya API, Mudbox SDK, FBX SDK, and Softimage SDK (and 3ds Max SDK)!
Enjoy,
Kristine
Comments
You can follow this conversation by subscribing to the comment feed for this post.