Eyeon:Script/General Concepts/Objects
From VFXPedia
Contents |
Getting Started: Objects
Objects
An object is a package that collects all of the logic involved in manipulating some item into one place. Objects consist of functions used to manipulate the object, properties that describe the environment of the object, and attributes that control its behavior. To make the idea plainer, consider the example of an automobile as an object.
When you drive a car, several different steps take place to cause the vehicle to move forward. You may start the engine, take the car out of park, take your foot off the brake and depress the accelerator, and adjust your steering. While driving you check your mirrors, and signal any turns you may have to take. If we imagine the car to be an object, then the functions provided by that object might be as follows :
car:Start() car:ShiftGears() car:Accelerate() car:Steer() car:CheckRearView() car:CheckSideView() car:SignalTurn()
If we wanted to know more about the car itself, we would access the objects properties and attributes,
car.Colour car.NumberOfSeats car.CurrentGear car.IsCarParked
Since all of these functions and properties are related to the operation of a single entity (the automobile) it makes sense to package them into a single object. This also allows us to hide the complexities of some operations. Running a function like car:Start() implies that you will also release the brake if the brake is currently applied. A function like Start() can include that logic, so that you do not have to remember check if the brake is engaged before calling the Start() function.
Our example is somewhat frivolous, but it shows the basic concept behind objects quite clearly.
Accessing Objects from eyeonScript
When using objects in eyeonScript, you call a function which returns a handle that points to that object in memory. When you assign that handle to a variable you can then use the handle to call the functions and properties associated with that object.
For example, to create a connection to Fusion you would call the Fusion() function, which will return a handle to the object used to control Fusion.
fusion = Fusion()
Calling the function fusion:NewComp() will cause Fusion to create a new composition, and the function will return a handle to the object for the newly created composition.
Several functions return a table containing a list of existing objects. For example, the fusion:GetCompList() function returns a table containing handles for each of the compositions currently open in an instance of Fusion. The tool:GetInputList() function returns a table of objects related to all inputs currently available for that tool object.
To release a handle to an object assign the variable containing the object to nil. For example :
-- obtain a handle to the fusion object on remote computer fusion = Fusion("192.168.1.10") -- release the handle fusion = nil
Accessing Object Functions and Properties
To use the functions contained within an object use the 'ObjectName:Function()' syntax. For example, to create a new Composition using the Fusion object you would call Fusion:NewComp().
fusion = Fusion() composition = fusion:NewComp()
You can access the properties of an object using the 'ObjectName.Property' syntax. For example to read the CurrentTime property from a composition object you could enter composition.CurrentTime.
Object Help
A list of the functions and properties available from each Fusion object is available using the Help() function. See the Help() reference documentation for details.
Fusions Object Model
Fusion
The fusion object is the parent object for all operations performed with Fusion. All of the comps and bins in Fusion are sub-objects contained by a parent fusion object.
Fusion()
Composition
Each composition running in Fusion exposes a composition object used to manipulate and control that composition. The tool objects in a composition are sub-objects of the composition object.
fusion:NewComp() fusion:GetCurrentComp() fusion:LoadComp()
Tool
The tool object is used to manipulate and control individual tools; those that are visible nodes in Fusion's Flow view, modifiers that can be seen in the Modifier view, and various animation curves. You can get a table of all tools contained within the current composition with the following:
composition:GetToolList()
Input
The controls on a tool are known in scripting as Inputs. The image inputs shown on the comp are also inputs. This object is used to read and manipulate these inputs.
tool:GetInputList()
Output
Each tool exposes two or more output objects which are used to connect the result of the tool to another, and for establishing previews. Most tool outputs are image based, but modifiers and expressions have numeric outputs.
tool:GetOutputList() input:GetConnectedOutput()
File
The file object allows you to read and write files from disk from the context of the fusion object. Since eyeonScript can remotely control Fusion, this may not be the same context as the script itself. (i.e. c:\file.ext may not be the same file from the computer running eyeonScript as it is on the computer running Fusion.
Queue Manager
This object is used to script the functionalities related to the render manager portion of Fusion. A number of functions are available to the render manager and are displayed below.
fusion.RenderManager
Render Slave
This object is used to manipulate and get data about the status of slaves connected to a Queue Manager object.
fusion.RenderManager:GetSlaveList()
Render Job
The render job object is used to manipulate and get data about the status of jobs that are in the queue of a Queue Manager.
fusion.RenderManager:GetJobList()