Tips and Techniques/Text/Text From a File

From VFXPedia

Jump to: navigation, search

Summary

Animated text from an external file (Last Updated: August 31st, 2007)

This tip demonstrates an intool script for the Text tool that will display 1 line from an external text file every 'x' frames.

Contents


Inspired by the following post to the fusion-l mailing list on August 31st, 2007


From    : Tuvok Shakur 
Sent    : Friday, August 31, 2007 11:55 AM
To      : fusion-l@laffeycomputer.com
Subject : [DF] Cycling Text: Any Ideas?

I'm trying to work on an effect where I have about 100 lines of text, 
but I only want to show each line for 2 frames then go to the next one. 
I know I can brute force it with 100 merges and 100 text+ nodes, but I
was wondering if any of  you could think of a more elegant solution.

Thanks!
Tuvok


An Intool Script solution

One solution is to use the intool script capability in fusion to read the text file from disk into a table, then display 1 line from the table every 2 frames.

To do this add a text tool to a composition, the open the script tab in the tools controls. This is the tab labeled with an icon of a red gear. Enter the following into the Start Render Script edit box

f = [[Z:\title.txt]]
interval = 2
t = {}
 
for l in io.lines(f) do
  table.insert(t, l)
end
 
num_lines = table.getn(t)

The first line should be edited to point to a text file which contains several lines of text. The second line should be also be modified so that the value of interval is equal to the number of frames each line of text will be displayed for.

Now enter the following into the Frame Render Script edit box

index = math.floor(time / interval) + 1
 
if index > num_lines then
  index = num_lines
end
 
StyledText = t[index]


That's all there is to it. If your composition does not start at frame 0, the first line of the Frame Render script can be modified to remove the + 1.

index = math.floor(time / interval)

You can also download a settings file for the text tool that implements the above.


Alternative Solutions

Members of the fusion-l mailing list also proposed the following alternative solutions.


Krokrodove

Sander de Regt and Raf Schoenmaekers suggested downloading the Krokodove plugins from www.komkomdoorn.com. One of the level 1 (free) tools in that set is a modifier called From file. Once the plugins are installed, simply right click in the Text tools edit box and select Modify With \ From File from the context menu.

Set the Format option in the modifiers controls to "Each line a frame" then follow the text with a Time Speed tool set to 0.5 with the interpolate option disabled.

See the KroKroDove documentation for more information on these powerful tools.


Using an animated mask

Attila Sziklai mentioned this would also be possible by using a simple expression. Attila was kind enough to provide an example composition, with the following commentary.

I set the space between lines to match the screen Y size.
Then I added an expression to the center that moves the layout up one screen frame by frame.
The timespeed after defines the delay of each screen.

It should be noted that for a large amount of text this could end up being rather slow.