Jump to: Board index » General » Fusion

Commandline scripting - tutorials?

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

Darren Cook

  • Posts: 13
  • Joined: Fri Sep 29, 2017 3:31 pm

Commandline scripting - tutorials?

PostTue Nov 14, 2017 10:15 pm

(I read the scripting guide - it was for Fusion 8, but I assume nothing major changed - but it was mostly reference, and I can't quite grasp what a full commandline script looks like.)

I'm wondering if it is possible to take a list of text strings, e.g. in a csv file, and use Fusion to generate one movie file for each line in that csv file, using an existing Fusion comp file as the template. E.g. I can imagine this workflow, from say a Python script: start Fusion, load in the comp file, change the text string, save the output filename, render; then repeat for the next line of text.

Alternatively, as the comp files are plain text, we could easily write a script (in any language) to generate one comp file per line in the csv file. Can we then use commandline scripting to automate the process of opening each comp file and doing the render. (Maybe this would be done as a Utility script?)

Any pointers to tutorials, or even just example scripts, of either workflow idea, would be very welcome.
Offline

Sander de Regt

  • Posts: 609
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Commandline scripting - tutorials?

PostTue Nov 14, 2017 10:20 pm

I'd suggest starting at this page

https://www.steakunderwater.com/VFXPedi ... ul_Scripts

for examples of the past that - with a little adapting - can still be used in current versions of Fusion.

If you need additional help with scripting go to www.steakunderwater.com and look for the sections on macros and scripting. There are very advanced scripters hanging around there who are more than willing to support people who try to learn more about Fusion and its scripting abilities.
Offline

Darren Cook

  • Posts: 13
  • Joined: Fri Sep 29, 2017 3:31 pm

Re: Commandline scripting - tutorials?

PostWed Nov 15, 2017 4:58 pm

Thanks - the first-listed script was basically what I was trying to do.

In case anyone else is looking to do the same, it needed a bit of hacking: most of the for loops needed me to add `pairs()`. E.g.
Code: Select all
     for i, input in tool:GetInputList(inpType) do
became:
Code: Select all
     for i, input in pairs(tool:GetInputList(inpType)) do


I also changed:
Code: Select all
    return strText:gsub("(%W)","_")
to:
Code: Select all
    return strText:gsub("%s+","_")
and in AddTrailingSlash() I changed the default to be "/", as I'm on Linux.

(The regex change was due to trying unicode. The Linux filesystem copes fine if everything is in UTF-8; being as the data is coming from csv there is no LF/CR, so I think I could've dropped the gsub() completely, but decided to replace whitespace with underline just in case.)

In my save node I set it to PNG, and set the filename to "/tmp/afusion_test/0000.png", and checked "Create folder during render". The script created these three directories:
/tmp/afusion_test/01_Hello_World!/
/tmp/afusion_test/02_日本語だ!/
/tmp/afusion_test/03_ABC/

(I've only tried a single column csv file, so far.)

Return to Fusion

Who is online

Users browsing this forum: No registered users and 2 guests