Eyeon:Script/PeyeonScript

From VFXPedia

Jump to: navigation, search


Python Bindings for EyeonScript

Contents


Description

PeyeonScript is a Python binding for eyeonscript. This allows for direct control over Fusion from within a Python script.


Requirements

Python 2.5 or later.


Installing

To install PeyeonScript, download and install the executable linked below.

Media:PeyeonScript-5.2.win32-py2.5.zip

The installer will look for your current installation of Python in the registry and default folders. Generally this is C:\Python25\. Given a default installation, the PeyeonScript files would then be installed to C:\Python25\Lib\site-packages\.


Using

To use the eyeonscript bindings within a python script, you must first import the bindings using the import keyword, as in the following example

import PeyeonScript as eyeon

You could then connect to a running instance of Fusion using the eyeon.scriptapp function

fusion = eyeon.scriptapp("Fusion")

From this point almost all functions, members and parameters work exactly as documented within the eyeonScript Reference documentation. You must take into account the differences between Python and eyeonscript – the table format in particular is similar, but different in syntax.


Examples

The following example connects to a running copy of Fusion on the local workstation, opens a new composition, sets the global and render ranges, adds several tools, animates a control, displays the last tool in a view, then plays the result.

import random
import PeyeonScript as eyeon
 
fu = eyeon.scriptapp("Fusion")
 
comp = fu.NewComp()
 
comp.SetAttrs({
	'COMPB_HiQ':          True,
	'COMPN_GlobalStart':   0.0,
	'COMPN_GlobalEnd':   100.0,
	'COMPN_RenderStart':   0.0,
	'COMPN_RenderEnd':   100.0,
	})
 
bg = comp.FastNoise({ 'Detail': 7 })
fg = comp.TextPlus({ 'StyledText': 'Python!', 'Size': 0.3 })
 
mg1 = comp.Merge({ 'Background': bg, 'Foreground': fg })
 
mg1.Angle = 25
mg1.Size = comp.BezierSpline()
 
for i in range(11):
	mg1.Size[i*10] = random.random() + 0.5
 
comp.CurrentFrame.ViewOn(mg1, 1)
 
comp.CurrentFrame.SwitchMainView('SplineEditorView')
 
comp.Play()

Issues and Problems

  • Due to a lack of support for ordered tables and hexadecimal data in Python 2.5, the eyeon.readfile and eyeon.writefile parser functions will not work in PeyeonScript
  • Certain functions which return multiple values will fail in Python. These functions provide alternates for use in python, which return their arguments as a dictionary instead. For example, from Python Flow:GetPos()should be replaced with GetPosTable()).

Functions known to have this issue include.

From GLViewer: GetPos()/GetPosTable(), GetRot()/GetRotTable(),

From GLView: GetPos()/GetPosTable(), GetRot()/GetRotTable(), GetSplit()/GetSplitTable()



Tips for PeyeonScript (edit)

  • It is probably a good idea to update PeyeonScript each time you perform a major Fusion update. It's not a big deal for minor changes - like Fusion 5.2 to Fusion 5.21, but for a change like Fusion 5.2 to Fusion 5.3 it would generally be wise to do so.
  • When you have problems connecting with the scriptapp check if you firewall permits the connection. (bFloch)