Action Example
##Silhouette Actions EXAMPLE - toggle opacity action with keybind
import fx
from fx import *
class toggleOpacity(Action):
def __init__(self):
if fx.version >= 5.0:
Action.__init__(self, 'Mo Tools|toggleOpacity alt+u' , root='MO')
else:
Action.__init__(self, 'Mo Tools|toggleOpacity alt+u')
def execute(self):
s = fx.selection()
fx.beginUndo("Toggle Opacity")
frame = fx.player.frame
for shape in s:
opacity = shape.property("opacity")
if opacity:
value = opacity.getValue(frame)
value = 100.0 - value
opacity.constant = False
opacity.setValue(value, frame)
fx.endUndo()
fx.addAction(toggleOpacity())
# Keybind
def toggleOpacity():
action = fx.actions["toggleOpacity"]
action.execute()
fx.bind('alt+u', toggleOpacity)