This is super useful if you want the user of your macros (or modified standard tools) to execute some additional functions right where he's using the tool. Previously, your first option was a tool script that the user had to find somewhere deep inside a context menu. Your second option was a custom menu command but that requires you to explain to your tool's users that they need to configure a menu somewhere.
So... long story short, you can now have a button that executes scripts.
More explanations from Peter Loveday can be found on pigsfly.
edit: I'll just quote Peter here so the documentation isn't scattered across the web
As has been partially pointed out, some variables are available for the script execution:
Generally tool and comp are probably the most useful; the button input is of limited value. However, it does allow the same script file to be used with multiple buttons, and dispatch based on Input ID. The intention here being it may be more desirable in terms of maintainability and distribution to have a single external script used for several buttons within the same setting, rather than a collection of them.
- comp - the current Composition
- tool - the Tool that owns this button
- self - the Input for the button itself
As with most places script snippets can be used, it is possible to use a variety of prefixes to alter behaviour here:
- An @ symbol at the start will specify that this is a filename, rather than a script snippet. This path will be mapped with the Comp's path-mappings, in some cases it might be desirable to position the script alongside the setting file. (Also see above comment regarding reuse of a single script with multiple buttons) eg:
The script file language will be detected from the extension in this case. Python scripts with ".py", "py2" or ".py3" will force the appropriate language.
Code: Select all
BTNCS_Execute = "@Scripts:Blah.eyeonscript"
- A language prefix can be applied. The default is Lua, but one can override that with using an ! and language name. Currently supported options are:
"!Lua: " - Lua script - default
"!Py2: " - Python 2.x script
"!Py3: " - Python 3.x script
"!Py: " - Python default version script
Note the colon and space must be included, eg:
Code: Select all
BTNCS_Execute = "!Py3: print(tool)"