-
Notifications
You must be signed in to change notification settings - Fork 1
/
node_operator.py
55 lines (37 loc) · 1.32 KB
/
node_operator.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import bpy
import time
from .node_system import *
class PearlExecOperator(bpy.types.Operator):
bl_idname = "pearl.node_exec"
bl_label = "Apply"
@classmethod
def poll(cls, context):
return getattr(context.space_data, 'tree_type', 'PearlNodeTree') == 'PearlNodeTree'
def execute(self, context):
self.executeNodeTree(context)
return {'FINISHED'}
def executeNodeTree(self,context):
# 当前树 : context.space_data.edit_tree
start = time.time()
current_tree = context.space_data.edit_tree
current_tree.executeNodes()
end = time.time()
total_time = (end - start)
print("------------------")
print("nodes number: ",len(current_tree.nodes))
self.report({"INFO"},"finish execute node trees: "+str(total_time)+'s')
def draw_menu(self, context):
if context.area.ui_type == 'PearlNodeTree':
self.layout.separator()
self.layout.operator(PearlExecOperator.bl_idname, text="Pearl Node Exec")
classes = [
PearlExecOperator,
]
def register():
for c in classes:
bpy.utils.register_class(c)
bpy.types.NODE_MT_context_menu.append(draw_menu)
def unregister():
for c in reversed(classes):
bpy.utils.unregister_class(c)
bpy.types.NODE_MT_context_menu.remove(draw_menu)