-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExtClearScriptFile.py
More file actions
56 lines (42 loc) · 1.37 KB
/
ExtClearScriptFile.py
File metadata and controls
56 lines (42 loc) · 1.37 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
class ExtClearScriptFile:
def __init__(self, ownerComp):
self.ownerComp = ownerComp
@property
def tags(self):
return self.ownerComp.par.Tags.eval().split(" ")
def OnClearselected(self):
_ops = ui.panes.current.owner.selectedChildren
self.__clear(_ops)
def OnClearcomp(self):
_ops = ui.panes.current.owner.findChildren(type=DAT, tags=self.tags, allTags=True, maxDepth=1)
self.__clear(_ops)
pass
def OnClearcompchildren(self):
_ops = ui.panes.current.owner.findChildren(type=DAT, tags=self.tags, allTags=True)
self.__clear(_ops)
pass
def OnClearall(self):
_ops = root.findChildren(type=DAT, tags=self.tags, allTags=True)
self.__clear(_ops)
pass
def __restoreTags(self, isUndo, _ops):
if not isUndo:
return
for _op in _ops:
if _op.isDAT and (_filepar := getattr(_op.par, 'file', None)):
for _tag in self.tags:
if _tag not in _op.tags:
_op.tags.add(_tag)
_op.color = (1, 0.5, 0.5)
def __clear(self, _ops):
ui.undo.startBlock('Clear Externalized Script Files')
ui.undo.addCallback(self.__restoreTags, info = _ops)
for _op in _ops:
if _op and all(_tag in _op.tags for _tag in self.tags):
if _op.isDAT and (_filepar := getattr(_op.par, 'file', None)):
_filepar.val = ""
_op.color = (0.55,0.55,0.55)
for _tag in self.tags:
if _tag in _op.tags:
_op.tags.remove(_tag)
ui.undo.endBlock()