Eyeon:Script/Reference/Applications/Fuse/Classes/ScriptOperator/AddOutput
From VFXPedia
Contents |
Summary
The AddOutput function is typically found within the Create section of a Fuse. It is used to add outputs to the tool. A tool generally only has one output, which is connected to the next tool in the flow's processing tree. It is possible for a tool to have multiple outputs, but rarely useful.
Usage
tool:AddOutput(string labelname, string scriptname, table attributes)
- labelname (string, required)
- This string value specifies the label displayed when the artist places the mouse pointer over the output on the tools tile. The labelname allows spaces, and so typically is used to present a 'friendly' name for an output compared to the scripting name described in the second argument.
- scriptname (string, required)
- This string value specifies the name of the control for purposes of saving the control value and for scripting it. The scriptname must not have any spaces, and contain only pure alphanumeric characters.
- attributes (table, required)
- This argument accepts a table of attributes used to define the properties of the output. Properties like minimum and maximum value, whether the tool accepts integer values only, or the options available in a drop down menu are all set within this table. A list of commonly used attributes is displayed below. A comprehensive list is provided later in this document.
LINKID_DataType string : specifies the type of data produced and used by the control. A control which expects or outputs an image would use type "Image" while a slider would use "Number". Valid values include : - Image
LINK_Main integer : specifies the priority or order of LINK style controls. This is used when calculating autoconnection of tools in the flow.
.
Example
The following example comes from the Gain.Fuse found on the Example Fuses page.
function Create() InMethod = self:AddInput("Method", "Method", { LINKID_DataType = "Number", INPID_InputControl = "ComboControl", INP_Default = 0.0, INP_Integer = true, { CCS_AddString = "Simple Loop", }, { CCS_AddString = "DoMultiProcess", }, { CCS_AddString = "ProcessPixels", }, { CCS_AddString = "MultiProcessPixels", }, }) InGain = self:AddInput("Gain", "Gain", { LINKID_DataType = "Number", INPID_InputControl = "SliderControl", INP_Default = 2.0, }) InImage = self:AddInput("Input", "Input", { LINKID_DataType = "Image", LINK_Main = 1, }) OutImage = self:AddOutput("Output", "Output", { LINKID_DataType = "Image", LINK_Main = 1, }) end
Tips for AddOutput (edit)
Additional Outputs
It might be useful to add additional outputs that other inputs can connect to. For example, the Tracker provides several outputs for its stabilized and unstabilized coordinates. This snippet is from the FlareCircle Fuse, that publishes additional coordinates like this:
OutActualPosition = self:AddOutput("Actual Position", "ActualPosition", { LINKID_DataType = "Point", }) OutOrientation = self:AddOutput("Orientation", "Orientation", { LINKID_DataType = "Number", })
If you use additional outputs like this, you also need to handle the PreCalcProcess event. This function is used to tell Fusion about the expected image size, DoD and so on, before the actual Process() function is called. By default it will only handle the main image output causing tools connected to the additional outputs to fail. No biggie, just override PreCalcProcess() and produce valid values for all your outputs:
function PreCalcProcess(req) local img = InImage:GetValue(req) -- of course you would need to calculate proper return values here... OutActualPosition:Set(req, Point(0.5,0.5)) OutOrientation:Set(req, Number(180)) -- output image with no data local out = Image({IMG_Like = img, IMG_NoData = true}) OutImage:Set(req, out) end