Skip to content

Commit 43a9d4b

Browse files
committed
add global settings for refresh
1 parent 242acd2 commit 43a9d4b

File tree

6 files changed

+69
-40
lines changed

6 files changed

+69
-40
lines changed

bseq/__init__.py

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,18 @@
1+
from bseq.utils import refresh_obj
12
from .operators import BSEQ_OT_load, BSEQ_OT_edit, BSEQ_OT_resetpt, BSEQ_OT_resetmesh, BSEQ_OT_resetins, BSEQ_OT_set_as_split_norm, BSEQ_OT_remove_split_norm, BSEQ_OT_disable_selected, BSEQ_OT_enable_selected, BSEQ_OT_refresh_seq
23
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property
34
from .panels import BSEQ_UL_Obj_List, BSEQ_List_Panel, BSEQ_Settings, BSEQ_Import, BSEQ_Templates, BSEQ_UL_Att_List, draw_template
45
from .messenger import subscribe_to_selected, unsubscribe_to_selected
56
import bpy
67
from bpy.app.handlers import persistent
78
from .importer import update_obj
8-
from datetime import datetime
9-
import os
10-
11-
12-
def print_information(scene):
13-
if not bpy.context.scene.BSEQ.print:
14-
return
15-
now = datetime.now()
16-
path = bpy.context.scene.render.filepath
17-
path = bpy.path.abspath(path)
18-
if not os.path.isdir(path):
19-
# by default, path is '/tmp', and it does not exist on windows system
20-
return
21-
filepath = path + '/bseq_' + now.strftime("%Y-%m-%d_%H-%M")
22-
with open(filepath, 'w') as file:
23-
file.write("Render Time: {}\n".format(now.strftime("%Y-%m-%d_%H-%M")))
24-
file.write("bseq Objects in the scene:\n\n")
25-
for obj in bpy.data.objects:
26-
bseq_prop = obj.BSEQ
27-
if bseq_prop.init:
28-
file.write("Object name: {}\n".format(obj.name))
29-
file.write("Is it being animated: {}\n".format(bseq_prop.enabled))
30-
file.write("Filepath: {}\n".format(bseq_prop.pattern))
31-
file.write("Is it relative path: {}\n".format(bseq_prop.use_relative))
32-
file.write("\n\n")
9+
from .globals import *
3310

3411

3512
@persistent
3613
def BSEQ_initialize(scene):
3714
if update_obj not in bpy.app.handlers.frame_change_post:
15+
bpy.app.handlers.frame_change_post.append(auto_refresh)
3816
bpy.app.handlers.frame_change_post.append(update_obj)
3917
subscribe_to_selected()
4018
if print_information not in bpy.app.handlers.render_init:

bseq/globals.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# here are the implementations of global settings
2+
3+
import bpy
4+
from datetime import datetime
5+
import os
6+
from .utils import refresh_obj
7+
8+
def print_information(scene):
9+
if not bpy.context.scene.BSEQ.print:
10+
return
11+
now = datetime.now()
12+
path = bpy.context.scene.render.filepath
13+
path = bpy.path.abspath(path)
14+
if not os.path.isdir(path):
15+
# by default, path is '/tmp', and it does not exist on windows system
16+
return
17+
filepath = path + '/bseq_' + now.strftime("%Y-%m-%d_%H-%M")
18+
with open(filepath, 'w') as file:
19+
file.write("Render Time: {}\n".format(now.strftime("%Y-%m-%d_%H-%M")))
20+
file.write("bseq Objects in the scene:\n\n")
21+
for obj in bpy.data.objects:
22+
bseq_prop = obj.BSEQ
23+
if bseq_prop.init:
24+
file.write("Object name: {}\n".format(obj.name))
25+
file.write("Is it being animated: {}\n".format(bseq_prop.enabled))
26+
file.write("Filepath: {}\n".format(bseq_prop.pattern))
27+
file.write("Is it relative path: {}\n".format(bseq_prop.use_relative))
28+
file.write("\n\n")
29+
30+
31+
def auto_refresh(scene, depsgraph=None):
32+
if not bpy.context.scene.BSEQ.auto_refresh:
33+
return
34+
for obj in bpy.data.objects:
35+
if obj.BSEQ.init == False:
36+
continue
37+
if obj.BSEQ.enabled == False:
38+
continue
39+
if obj.mode != "OBJECT":
40+
continue
41+
refresh_obj(obj)

bseq/operators.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import fileseq
33
from .messenger import *
44
import traceback
5-
from .utils import show_message_box
5+
from .utils import refresh_obj, show_message_box
66
from .importer import create_obj
77
import numpy as np
88

@@ -112,7 +112,7 @@ def execute(self, context):
112112
gn = obj.modifiers.new("BSEQ_GeometryNodse", "NODES")
113113
# change starting from blender 3.2
114114
# https://developer.blender.org/rB08b4b657b64f
115-
if bpy.app.version >= (3,2,0):
115+
if bpy.app.version >= (3, 2, 0):
116116
bpy.ops.node.new_geometry_node_group_assign()
117117
gn.node_group.nodes.new('GeometryNodeMeshToPoints')
118118
set_material = gn.node_group.nodes.new('GeometryNodeSetMaterial')
@@ -147,7 +147,7 @@ def execute(self, context):
147147
gn = obj.modifiers.new("BSEQ_GeometryNodse", "NODES")
148148
# change starting from blender 3.2
149149
# https://developer.blender.org/rB08b4b657b64f
150-
if bpy.app.version >= (3,2,0):
150+
if bpy.app.version >= (3, 2, 0):
151151
bpy.ops.node.new_geometry_node_group_assign()
152152
bpy.ops.object.modifier_move_to_index(modifier=gn.name, index=0)
153153
return {"FINISHED"}
@@ -172,7 +172,7 @@ def execute(self, context):
172172
gn = obj.modifiers.new("BSEQ_GeometryNodse", "NODES")
173173
# change starting from blender 3.2
174174
# https://developer.blender.org/rB08b4b657b64f
175-
if bpy.app.version >= (3,2,0):
175+
if bpy.app.version >= (3, 2, 0):
176176
bpy.ops.node.new_geometry_node_group_assign()
177177
nodes = gn.node_group.nodes
178178
links = gn.node_group.links
@@ -270,15 +270,6 @@ class BSEQ_OT_refresh_seq(bpy.types.Operator):
270270
def execute(self, context):
271271
scene = context.scene
272272
obj = bpy.data.objects[scene.BSEQ.selected_obj_num]
273-
274-
fs = obj.BSEQ.pattern
275-
if obj.BSEQ.use_relative:
276-
fs = bpy.path.abspath(fs)
277-
fs = fileseq.findSequenceOnDisk(fs)
278-
fs = fileseq.findSequenceOnDisk(fs.dirname() + fs.basename() + "@" + fs.extension())
279-
fs = str(fs)
280-
if obj.BSEQ.use_relative:
281-
fs = bpy.path.relpath(fs)
282-
obj.BSEQ.pattern = fs
273+
refresh_obj(obj)
283274

284275
return {"FINISHED"}

bseq/panels.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ def draw(self, context):
208208

209209
col1.label(text="Print Sequence Information on Render")
210210
col2.prop(importer_prop, "print", text="")
211+
col1.label(text="Auto refresh all the sequence every frame")
212+
col2.prop(importer_prop, "auto_refresh", text="")
211213

212214

213215
class BSEQ_Templates(bpy.types.Menu):

bseq/properties.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ class BSEQ_scene_property(bpy.types.PropertyGroup):
4141
description="whether or not to print additional information when rendering",
4242
default=True)
4343

44+
auto_refresh: bpy.props.BoolProperty(name='auto refresh',
45+
description="whether or not to auto refresh all the sequence every frame",
46+
default=False)
47+
4448

4549
class BSEQ_obj_property(bpy.types.PropertyGroup):
4650
init: bpy.props.BoolProperty(default=False)
@@ -52,6 +56,7 @@ class BSEQ_obj_property(bpy.types.PropertyGroup):
5256
pattern: bpy.props.StringProperty()
5357
frame: bpy.props.IntProperty()
5458

59+
5560
# set this property for mesh, not object (maybe change later?)
5661
class BSEQ_mesh_property(bpy.types.PropertyGroup):
5762
split_norm_att_name: bpy.props.StringProperty(default="")

bseq/utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import bpy
2-
2+
import fileseq
33

44
def show_message_box(message="", title="Message Box", icon="INFO"):
55
'''
@@ -24,3 +24,15 @@ def stop_animation():
2424
# if playing animation, then stop it, otherwise it will keep showing message box
2525
bpy.ops.screen.animation_cancel()
2626

27+
28+
29+
def refresh_obj(obj):
30+
fs = obj.BSEQ.pattern
31+
if obj.BSEQ.use_relative:
32+
fs = bpy.path.abspath(fs)
33+
fs = fileseq.findSequenceOnDisk(fs)
34+
fs = fileseq.findSequenceOnDisk(fs.dirname() + fs.basename() + "@" + fs.extension())
35+
fs = str(fs)
36+
if obj.BSEQ.use_relative:
37+
fs = bpy.path.relpath(fs)
38+
obj.BSEQ.pattern = fs

0 commit comments

Comments
 (0)