The Plugins feature allows to run custom python scripts directly from Synfig Studio menu. Each script takes .sif file as first argument and should modify its contents in some way. After script execution finished, the file is automatically reopened back in Synfig Studio.
With the current script feature, has it work with the file itself you can't retrieve the current Time Cursor position when the script is invoked. But you can know the value of a Parameter or ValueNode at a certain time (the ones fixed by Waypoints), because the Animated Value Nodes are stored (other problem is to know the interpolated value, which is not trivial for other thing rather than Linear or Constant interpolation)
All plugins are located in the "Plug-Ins" submenu of the canvas.
People often write some scripts to make useful things on Synfig (sif) files. The most of these scripts are written in python. But for ordinary users running custom scripts from terminal is tricky. With plugins feature user can install scripts as easy as they copy files and transparently run them in the same way as they use standard Synfig Studio commands. Also, runing scripts from menu is much faster than from terminal and it greatly improves the workflow for advanced users. Having this feature allows to easily add simple functions to Synfig Studio by writting scripts in python.
How to install plugins
Plugin is a directory, containing the python script (*.py file), plugin.xml and maybe some other files if they are required by python script.
To install the plugin user should copy its directory into the following location:
- Windows Vista/7/8: C:\Users\USERNAME\Synfig\plugins
- Windows XP: C:\Documents and Settings\USERNAME\Synfig\plugins
- Linux: ~/.config/synfig/plugins
- OSX: /Users/USERNAME/Library/Synfig/plugins
The system-wide location for the plugins is USER_DIRECTORY/SYNFIG_CONFIGURATION_DIR/plugins
Where to find plugins
- Yoyobuae:FreeForm Deform
- Morevna:Plugins feature in Synfig Studio
- Berteh:Import Labels and Timings
- Synfig forum: scripts/plugin thread
Each plugin located in a separate subdirectory with unique name. The part of the name before first "-" symbol is used to set the group plugin belongs to (not implemented yet). The main information about plugin (plugins name and script to execute) is stored in the plugin.xml file. It's self-explanatory :
<?xml version="1.0" encoding="UTF-8"?> <plugin> <name>Unhide All Layers</name> <name xml:lang="es">Activa todas las capas</name> <name xml:lang="eu">Erakutsi geruza guztiak</name> <name xml:lang="eu_ES">Erakutsi geruza guztiak</name> <name xml:lang="fr">Afficher Tous les Calques</name> <name xml:lang="lt">Parodyti visus sluoksnius</name> <name xml:lang="ru">Показать все скрытые слои</name> <exec>view-unhide-all-layers.py</exec> </plugin>
#!/usr/bin/env python # # Copyright (c) 2012 by Konstantin Dmitriev <k....z...gmail.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. import os import sys def process(filename): # Read the input file inputfile_f = open(filename, 'r') inputfile_contents = inputfile_f.readlines() inputfile_f.close() # Now write results to the same file inputfile_f = open(filename, 'w') for line in inputfile_contents: if "<layer " in line: inputfile_f.write(line.replace(' active="false" ',' active="true" ')) else: inputfile_f.write(line) inputfile_f.close() if len(sys.argv) < 2: sys.exit() else: process(sys.argv)
All scripts are interpreted with python 3.
In Linux and Mac OSX case Synfig Studio looks for "python" or "python3" binary. For windows case Python binary is expected at INSTALL_PREFIX/python/python.exe. New environment variable SYNFIG_PYTHON_BINARY allows to set custom path to the python 3 binary.