< Previous | Contents | Next >

Methods

Operator.AddModifier(input, modifier)

Creates a modifier and connects it to an input.

This provides an easy way to animate the controls of a tool. input ID of the tool’s Input to be connected to.

modifier ID of the modifier to be created. Returns a boolean value indicating success.


myBlur.Blend[100] = 0.0

myBlur.Blend[0] = 1.0

if myBlur.AddModifier(“Blend”, “BezierSpline”):

myBlur = comp.Blur()

> Python usage:



image

myBlur.Blend[100] = 0.0

end

myBlur.Blend[0] = 1.0

if myBlur:AddModifier(“Blend”, “BezierSpline”) then

myBlur = Blur()

> Lua usage:



image


> Parameters:

input (string) – input

modifier (string) – modifier

> Returns: success

> Return type: boolean

Operator.ConnectInput(input, target)

Connect or disconnect an Input.

The input can be connected to an Output or an Operator, or to nil, which disconnects the input.

If the target given is an Operator, the Input will be connected to that Operator’s main Output.

input the ID of an Input to connect

target an Output or Operator object to connect the input to, or nil to disconnect


image

# Find a Loader, and connect it to Merge1.Foreground

ldr = comp.FindToolByID(“Loader”) if ldr and comp.Merge1:

comp.Merge1.ConnectInput(“Foreground”, ldr)

> Python usage:


image

-- Find a Loader, and connect it to Merge1.Foreground

ldr = comp:FindToolByID(“Loader”)

if ldr and Merge1 then

print(comp.ActiveTool) Merge1:ConnectInput(“Foreground”, ldr)

end

> Lua usage:


image


> Parameters:

input (string) – input

target ((Tool|Output|nil)) – target

> Returns: success

> Return type: boolean

Operator.Delete()

Delete this tool.

Removes the tool from the composition. This also releases the handle to the Fusion Tool object, setting it to nil.

Operator.FindMainInput(index)

Returns the tool’s main (visible) input. index integer value of 1 or greater.


image

# Loop through all main inputs.

i = 1

while True:

inp = tool.FindMainInput(i) if inp is None:

break

# Got input

print(inp.GetAttrs()[“INPS_Name”]) i+=1

> Python usage:


image

-- Loop through all main inputs.

tool = comp.ActiveTool i = 1

while true do

inp = (tool:FindMainInput(i))

> Lua usage:


image



image

if inp == nil then break

end

-- Got input

end

i = i + 1

print (inp:GetAttrs().INPS_Name)

> Parameters:

index (number) – index

> Returns: inp

> Return type: Input

Operator.FindMainOutput(index)

Returns the tool’s main (visible) output.

index integer value of 1 or greater.


image

image

image

i = 1

# Loop through all main outputs.

outp = tool.FindMainOutput(i)

while True:

# Got output

break

if outp is None:

i+=1

print(outp.GetAttrs()[“OUTS_Name”])

> Python usage:



image


image

image

outp = (tool:FindMainOutput(i))

while true do

i = 1

tool = comp.ActiveTool

-- Loop through all main outputs.

-- Got output

end

break

if outp == nil then

> Lua usage:



end

i = i + 1

print (outp:GetAttrs().OUTS_Name)

> Parameters:

index (number) – index

> Returns: out

> Return type: Output

Operator.GetChildrenList([selected][, regid])

Returns a list of all children tools, or selected children tools.

This function is useful for finding members of Macro or Group tools.

selected Pass true to get only selected child tools.

regid pass a Registry ID string to get only child tools of that type. Returns a table of tool objects.


image


print(t.Name)

for t in comp.ActiveTool.GetChildrenList().values():

# list all tools in a group or macro

> Python usage:



end

print(t.Name)

for i,t in pairs(comp.ActiveTool:GetChildrenList()) do

-- list all tools in a group or macro

> Lua usage:



> Parameters:

selected (boolean) – selected

regid (string) – regid

> Returns: tools

> Return type: table

Operator.GetControlPageNames()

Returns a table of control page names, indexed by page number.

> Returns: names

> Return type: table

Operator.GetCurrentSettings()

Returns the index of the tool’s current settings slot.

A tool has 6 different collections/slots of settings. By default, it uses slot 1. Returns a numerical index of 1 or greater.

> Returns: index

> Return type: number

Operator.GetData([name])

Get custom persistent data. See Composition:GetData().

> Parameters:

name (string) – name


image


> Returns: value

> Return type: (number|string|boolean|table)

Operator.GetInput(id[, time])

Fetches the value of an input at a given time.

The time argument may be omitted, if the input is not animated.

A similar result may be obtained by simply indexing the input with the desired time.

id the ID of the input to be queried.

time the keyframe time to be queried.

Returns a number, string or other Parameter object, depending on the DataType of the queried Input.


print(tool.Blend[30])

print(tool:GetInput(“Blend”, 30.0))

# these lines: the same thing

> Python usage:



print(tool.Blend[30.0]

print(tool:GetInput(“Blend”, 30.0)

-- these lines do the same thing

> Lua usage:



> Parameters: id (string) – id

time (number) – time

> Returns: value

> Return type: (number|string|Parameter)

Operator.GetInputList([type])

Return a table of all inputs on this tool.

type can be used to filter the results to return only a specific datatype. Valid values include “Image”, “Number”, “Point”, “Gradient” and “Text”.

Returns a table containing handles all the Inputs available for the tool.


image


print(inp.GetAttrs()[“INPS_Name”])

for inp in x:

x = tool.GetInputList().values()

tool = comp.ActiveTool

# this Tool script prints out the name


# of every control on the selected tool

> Python usage:



image

for i, inp in pairs(x) do

x = tool:GetInputList()

tool = tool or comp.ActiveTool

-- this Tool script prints out the name


-- of every control on the selected tool

> Lua usage:



end

print(inp:GetAttrs().INPS_Name)

> Parameters:

type (string) – type

> Returns: inputs

> Return type: table

Operator.GetKeyFrames()

Return a table of all keyframe times for this tool.

Returns a table containing a list of keyframe times, in order, for the tool only. Any animation splines or modifiers attached to the tool’s inputs are not considered.

> Returns: keyframes

> Return type: table


image


Operator.GetOutputList([type])

Return a table of all outputs on this tool.

type can be used to filter the results to return only a specific datatype. Valid values include “Image”, “Number”, “Point”, “Gradient” and “Text”.

Returns a table containing handles all the Outputs available for the tool.


image

image

x = tool.GetOutputList().values()

tool = comp.ActiveTool

# this Tool script prints out the name


# of every output on the selected tool

print(outp.GetAttrs()[“OUTS_Name”])

for outp in x:

> Python usage:



image

image

for i,out in pairs(x) do

x = tool:GetOutputList()

tool = tool or comp.ActiveTool

-- this Tool script prints out the name


-- of every output on the selected tool


print(out:GetAttrs().OUTS_Name)

end

> Lua usage:



image


> Parameters:

type (string) – type

> Returns: outputs

> Return type: table

Operator.LoadSettings(filename)

Note: This method is overloaded and has alternative parameters. See other definitions. Load the tools’s settings from a file or table.

Used to load .setting files or tables into a tool. This is potentially useful for any number of applications, such as loading curve data into fusion or to synch updates to tools over project management systems.


image

settingtable = bmd.readfile(“fusion:\\settings\\ccv_project1.setting”) comp.ColorCurve1.LoadSettings(settingtable)

# Same as

> Python usage:


comp.ColorCurve1.LoadSettings(“fusion:\\settings\\ccv_project1.setting”)


image

-- Same as

ColorCurve1:LoadSettings(settingtable)

settingtable = bmd.readfile(“fusion:\\settings\\ccv_project1.setting”)

> Lua usage:


ColorCurve1:LoadSettings(“fusion:\\settings\\ccv_project1.setting”)


> Parameters:

filename (string) – filename

> Returns: success

> Return type: boolean


image


Operator.LoadSettings(settings)

Note: This method is overloaded and has alternative parameters. See other definitions. Load the tools’s settings from a file or table.

Used to load .setting files or tables into a tool. This is potentially useful for any number of applications, such as loading curve data into fusion or to synch updates to tools over project management systems.


image

settingtable = bmd.readfile(“fusion:\\settings\\ccv_project1.setting”)


comp.ColorCurve1.LoadSettings(settingtable)

# Same as

> Python usage:


comp.ColorCurve1.LoadSettings(“fusion:\\settings\\ccv_project1.setting”)


image

-- Same as

ColorCurve1:LoadSettings(settingtable)

settingtable = rbmd.readfile(“fusion:\\settings\\ccv_project1.setting”)

> Lua usage:


ColorCurve1:LoadSettings(“fusion:\\settings\\ccv_project1.setting”)


> Parameters:

settings (table) – settings

> Returns: success

> Return type: boolean

Operator.Refresh()

Refreshes the tool, showing updated user controls.

Calling Refresh will invalidate the handle to the tool. A new handle is returned and can be stored.

Returns a new handle to the refreshed tool.

Operator.SaveSettings(filename)

Note: This method is overloaded and has alternative parameters. See other definitions. Save the tool’s current settings to a file or table.


image


If a path is given, the tool’s settings will be saved to that file, and a boolean is returned to indicate success.

If no path is given, SaveSettings() will return a table of the tool’s settings instead.

> Parameters:

filename (string) – filename

> Returns: success

> Return type: boolean

Operator.SaveSettings(customdata)

Note: This method is overloaded and has alternative parameters. See other definitions. Save the tool’s current settings to a file or table.

If a path is given, the tool’s settings will be saved to that file, and a boolean is returned to indicate success.

If no path is given, SaveSettings() will return a table of the tool’s settings instead.

> Parameters:

customdata (boolean) – customdata

> Returns: settings

> Return type: table

Operator.SetCurrentSettings()

Sets the tool’s current settings slot.

If the slot is not empty, the function will change all the tool’s Inputs to the settings stored in that slot.

A tool has 6 different collections (“slots”) of settings. By default, it uses slot 1. Changing the current settings slot may change any or all of the tool’s Inputs to new values, or new animations, stored in the new slot (if any).

All of the tool’s previous settings are stored in the old slot, before changing to a new slot.

index numerical index of 1 or greater.


image

tool = comp.ActiveTool

import time

> Python usage:


slot = tool.GetCurrentSettings()


image



image

image

image


# change to new slot, and turn off the effect

# wait(a few seconds)

print(tool.Name + “. Before...”)

tool.SetCurrentSettings(slot + 1)


tool.Blend[comp.CurrentTime] = 0.0


# change back to the old slot, and turn the effect back on

tool.SetCurrentSettings(slot)

time.sleep(3)

image

image

tool = tool or comp.ActiveTool

end

while clock() - t0 <= n do end

local t0 = clock()

function sleep(n) -- seconds

local clock = os.clock


-- change to new slot, and turn off the effect

tool:SetCurrentSettings(slot + 1)

tool.Blend[comp.CurrentTime] = 0.0 print(tool.Name .. “: Before...”)

slot = tool:GetCurrentSettings()

print(tool.Name + “. After!”)

tool.Blend[comp.CurrentTime] = 1.0

> Lua usage:



image



image

image

image

-- wait(a few seconds)


-- change back to the old slot, and turn the effect back on

sleep(3)

tool.Blend[comp.CurrentTime] = 1.0

print(tool.Name .. “: After!”)

tool:SetCurrentSettings(slot)

> Returns: index

> Return type: number

Operator.SetData(name, value) Set custom persistent data. See Composition:SetData().

> Parameters:

name (string) – name

value ((number|string|boolean|table)) – value

Operator.SetInput(id, value, time)

Sets the value of an input at a given time.

The time argument may be omitted, if the input is not animated.

A similar result may be obtained by simply indexing the input with the desired time, and assigning to that.

> Parameters: id (string) – id

value ((number|string|Parameter)) – value

time (number) – time

Operator.ShowControlPage(name)

Makes the specified control page visible.

Valid ControlPageNames for the tool can be queried with GetControlPageNames().

> Parameters:

name (string) – name


image