|
|
(5 intermediate revisions by 3 users not shown) |
Line 1: |
Line 1: |
− | <!-- Page info -->
| + | This page is moved to https://synfig.readthedocs.io/en/latest/plugins.html |
− | {{Title|Plugins}}
| + | |
− | {{Category|Manual}}
| + | |
− | {{NewTerminology}}
| + | |
− | <!-- Page info end -->
| + | |
− | | + | |
− | = Summary =
| + | |
− | 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 {{l|Time_Cursor}} position when the script is invoked. But you can know the value of a {{l|Parameter}} or {{l|ValueNode}} at a certain time (the ones fixed by {{l|Waypoints}}), because the {{l|ValueNode#Animated ValueNodes|Animated Value Nodes}} are stored (other problem is to know the interpolated value, which is not trivial for other thing rather than {{l|Linear}} or {{l|Constant}} interpolation)
| + | |
− | | + | |
− | All plugins are located in the "Plug-Ins" submenu of the canvas.
| + | |
− | | + | |
− | = Rationale =
| + | |
− | 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
| + | |
− | | + | |
− | = Tutorial =
| + | |
− | | + | |
− | <videoflash>De9UhUkzNiY|425|344</videoflash>
| + | |
− | | + | |
− | | + | |
− | = Details =
| + | |
− | | + | |
− | 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 :
| + | |
− | | + | |
− | <pre><?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></pre>
| + | |
− | | + | |
− | view-unhide-all-layers.py :
| + | |
− | <pre>
| + | |
− | #!/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[1])
| + | |
− | </pre>
| + | |
− | | + | |
− | 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.
| + | |