Eyeon:Script/Reference/Applications/Fusion/Classes/Composition/AddTool
From VFXPedia
< Eyeon:Script | Reference | Applications | Fusion | Classes | Composition
Contents |
composition : AddTool
Arguments
AddTool(toolname,x,y)
- toolname(required, String)
The RegID of the tool to add
- x(optional, Number)
The X position of the tool in the flow view.
- y(optional, Number)
The Y position of the tool in the flow view.
Returns
A tool handle that can be used to control the newly added tool.
Remarks
AddTool functions similarly to the standard tool adding functions, except that it also gives options for the tool's position in the flow view.
Requirements
- eyeonScript 5.01
- Fusion 5.01
Examples
bg = comp:AddTool("Background",1,1) mg = comp:AddTool("Merge",5,5) mg.Background = bg.Output
Tips for AddTool (edit)
- In Fusion 6.2 the parameters for AddTool have been extended!
tool = AddTool(string id [, defsettings] [, xpos [, ypos]])
defsettings specifies whether user-modified default settings should be applied for the new tool (true) or not (false, default).
- You can use the number -32768 (the smallest negative value of a 16-bit integer) for both x and y position. This will cause Fusion to add the tool as if you had clicked on one of the toolbar icons. The tool will be positioned next to the currently selected one and a connection will automatically be made if possible.
- Unfortunately this does not return the proper tool before Fusion 6.2.
- -- In this case the new tool is added in a semi-asynchronous manner, which is why the tool handle isn't returned. However, the new tool becomes active, so you can obtain its handle with 'comp.ActiveTool'
- -- But this seems unreliable. If the AddTool automagically creates a Merge the merge is active instead of the created tool.
This seems to work better:
# ------------------------------------------------------------------------------------- def AddTool(type, posx=-32768, posy=-32768): """ If we use AddTool with the magic number to create the tool as if it was created from the toolbar it doesn't return a tool. This function makes sure we get what we expected. Written by B.Floch 08.04.2011 """ sel = comp.AddTool(type, posx, posy) if sel != None: return sel else: sel = comp.ActiveTool if sel.ID.lower() == type.lower(): # That's what we wanted return sel elif sel.ID.lower() == fusion.GetPrefs("Global.Default.Tools.Composite").lower(): # A merge or default tool has been created. # Get the foreground which should be our tool # Get the Foreground out = sel.FindMainInput(2).GetConnectedOutput() if out == None: # We don't have a foreground. Better just return what we got return sel return out.GetTool() else: # We don't have a clue. Better just return what we got return sel
- The RegID to add Fuses is prefixed by "Fuse.":
x = comp:AddTool("Fuse.FrameAverage")