-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcallback.py
More file actions
79 lines (60 loc) · 2.33 KB
/
callback.py
File metadata and controls
79 lines (60 loc) · 2.33 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import bpy
import fileseq
import traceback
import time
from .frame_buffer import init as framebuffer_init, terminate as framebuffer_terminate, queue_load as framebuffer_queue_load, flush_buffer as framebuffer_flush_buffer
from .importer import update_obj
from .utils import show_message_box
# Code here are mostly about the callback/update/items functions used in properties.py
file_sequences = []
def update_path(self, context):
'''
Detects all the file sequences in the directory
'''
# When the path has been changed, reset the selected sequence to None
context.scene.BSEQ['fileseq'] = 1
context.scene.BSEQ.use_pattern = False
context.scene.BSEQ.pattern = ""
file_sequences.clear()
p = context.scene.BSEQ.path
try:
f = fileseq.findSequencesOnDisk(bpy.path.abspath(p))
except Exception as e:
show_message_box("Error when reading path\n" + traceback.format_exc(),
"fileseq Error" + str(e),
icon="ERROR")
return None
if not f:
return None
if len(f) >= 30:
file_sequences.append(("None", "Too much sequence detected, could be false detection, please use pattern below", "", 1))
else:
count = 1
for seq in f:
file_sequences.append((str(seq), seq.basename() + "@" + seq.extension(), "", count))
count += 1
def item_fileseq(self, context):
return file_sequences
def update_selected_obj_num(self, context):
# Here is when select sequences, then change the corresponding object to active object
index = context.scene.BSEQ.selected_obj_num
obj = bpy.data.objects[index]
if context.scene.BSEQ.selected_obj_deselectall_flag:
bpy.ops.object.select_all(action="DESELECT")
obj.select_set(True)
context.view_layer.objects.active = obj
def poll_material(self, material):
return not material.is_grease_pencil
def poll_edit_obj(self, object):
return object.BSEQ.init
def update_framebuffer(self, context) -> None:
if self.buffer_next_frame:
framebuffer_init()
else:
framebuffer_terminate()
def load_obj(scene, depsgraph=None):
if scene.BSEQ.buffer_next_frame:
framebuffer_flush_buffer(scene, depsgraph)
framebuffer_queue_load(scene, depsgraph)
return
update_obj(scene, depsgraph)