EyeonTips:Script/Reference/Applications/Fusion Expressions/Introduction

From VFXPedia

Jump to: navigation, search

Contents

Assigning simple expression through script

To assign a simple expression to an attribute via scripting, use the SetExpression command.

Syntax: myTool.InputName:SetExpression(" expression text ")

Here are some examples:

myText.StyledText:SetExpression("Text(time)")
myBackground.Height.SetExpression("Width/2.35")

Accessing the Fusion object in InTool scripts

Comp and tool scripts can access a variable called fusion which contains an instance of the Fusion class. InTool scripts, however, don't have this variable set up by default. You can easily create it yourself. Just add this line to a tool's frame render script:

fusion = eyeon.scriptapp("Fusion", "localhost")

InTool script, that print (in console) full listing of tools in current composition

--tell WHO IS fusion:
fusion = eyeon.scriptapp("Fusion", "localhost")
--..and where we are:
comp = fusion:GetCurrentComp()
 --print all tools list in current comp:
dump(comp:GetToolList())

Example InTool script for 3D tool

InTool script that change tool attribute based on attribute from another 3Dobject, that connected to tool.SceneInput.

In this case we connect Locator3D.Size attribute to Camera3D.FLenght (camera connected to locator.SceneInput)

There is FlowView:


And there is locator InTool script:

                                  Start Render Script:
--tell WHO IS fusion:
fusion = eyeon.scriptapp("Fusion", "localhost")
--..and where we are:
comp = fusion:GetCurrentComp()
 
-- find this tool in current comp context
toollist = comp:GetToolList()
selfTool = nil
for i, tool in toollist do 
   if tool.Name == self.Name then 
      selfTool = tool
      break
    end
end
                                  Frame Render Script:
print("================")
 
inputObj = selfTool.SceneInput:GetConnectedOutput():GetTool()
Size = inputObj.FLength[comp.TIME_UNDEFINED]
print(inputObj.Name,"is connected to",self.Name)


Image parameter type

Instead of the .Width and .Height attributes mentioned above, you can also use .OriginalWidth and .OriginalHeight. These are the image dimensions without proxy scaling.


FuID parameter type

In addition to the point and text types described above, some controls in Fusion (mostly dropdowns) are using the FuID type. It's similar to a string, but you can't assign strings directly to these inputs in an InTool script (only comp and tool scripts can do this). Instead, turn a string into a FuID object like this:

-- create FuID from a string
f = FuID("The Value")
-- turn FuID into a string
print(f.Value)

See the snippets page for more FuID examples.