-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkmfx_changepaintOpacity.py
38 lines (29 loc) · 1.17 KB
/
kmfx_changepaintOpacity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import fx
from fx import *
fx.prefs.add("KMFX_Load.Change Paint Opacity", True)
class KMFXchangepaintOpacity(Action):
"""shortcuts to increase/decrease opacity when using paint node"""
def __init__(self):
if fx.prefs["KMFX_Load.Change Paint Opacity"] is True:
Action.__init__(self, "KMFX|Change Paint Opacity")
def available(self):
node = fx.activeNode()
try:
assert node.isType(
"PaintNode") and node is not None, "Paint node not active"
except Exception:
pass
def execute(self, **kwargs):
beginUndo("KMFX|Change Paint Opacity")
node = fx.activeNode()
mode = kwargs["mode"] if "mode" in kwargs.keys() else "increase"
if node.isType("PaintNode"):
increment = 10 if mode == "increase" else -10
x = fx.paint.opacity
i = (x + increment) / 100
fx.paint.opacity = i
else:
# this is only needed because the bind is made on keys 1 and 2
fx.viewer.viewMode = 0 if mode == "increase" else 1
endUndo()
addAction(KMFXchangepaintOpacity())