Skip to content

Commit 9298b2f

Browse files
Julius Stotzdigitalillusions
authored andcommitted
Added Enable/Disable All and the option to select a root directory for relative paths
1 parent 0351964 commit 9298b2f

File tree

8 files changed

+52
-12
lines changed

8 files changed

+52
-12
lines changed

__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
BSEQ_OT_disable_selected,
4343
BSEQ_OT_enable_selected,
4444
BSEQ_OT_refresh_seq,
45+
BSEQ_OT_disable_all,
46+
BSEQ_OT_enable_all,
4547
]
4648

4749

bseq/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from bseq.utils import refresh_obj
2-
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
2+
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, BSEQ_OT_disable_all, BSEQ_OT_enable_all
33
from .properties import BSEQ_scene_property, BSEQ_obj_property, BSEQ_mesh_property
44
from .panels import BSEQ_UL_Obj_List, BSEQ_List_Panel, BSEQ_Settings, BSEQ_Import, BSEQ_Templates, BSEQ_UL_Att_List, draw_template
55
from .messenger import subscribe_to_selected, unsubscribe_to_selected
@@ -43,4 +43,6 @@ def BSEQ_initialize(scene):
4343
"BSEQ_OT_disable_selected",
4444
"BSEQ_OT_enable_selected",
4545
"BSEQ_OT_refresh_seq",
46+
"BSEQ_OT_disable_all",
47+
"BSEQ_OT_enable_all",
4648
]

bseq/globals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ def auto_refresh(scene, depsgraph=None):
3838
continue
3939
if obj.mode != "OBJECT":
4040
continue
41-
refresh_obj(obj)
41+
refresh_obj(obj, scene)

bseq/importer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ def update_mesh(meshio_mesh, mesh):
137137
mesh.normals_split_custom_set_from_vertices(v)
138138

139139

140-
def create_obj(fileseq, use_relaitve, transform_matrix=Matrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]])):
140+
def create_obj(fileseq, use_relative, root_path, transform_matrix=Matrix([[1, 0, 0, 0], [0, 0, -1, 0], [0, 1, 0, 0], [0, 0, 0, 1]])):
141141

142142
current_frame = bpy.context.scene.frame_current
143143
filepath = fileseq[current_frame % len(fileseq)]
@@ -156,9 +156,9 @@ def create_obj(fileseq, use_relaitve, transform_matrix=Matrix([[1, 0, 0, 0], [0,
156156
name = fileseq.basename() + "@" + fileseq.extension()
157157
mesh = bpy.data.meshes.new(name)
158158
object = bpy.data.objects.new(name, mesh)
159-
object.BSEQ.use_relative = use_relaitve
160-
if use_relaitve:
161-
object.BSEQ.pattern = bpy.path.relpath(str(fileseq))
159+
object.BSEQ.use_relative = use_relative
160+
if use_relative:
161+
object.BSEQ.pattern = bpy.path.relpath(str(fileseq), start=root_path)
162162
else:
163163
object.BSEQ.pattern = str(fileseq)
164164
object.BSEQ.init = True
@@ -191,7 +191,7 @@ def update_obj(scene, depsgraph=None):
191191
meshio_mesh = None
192192
pattern = obj.BSEQ.pattern
193193
if obj.BSEQ.use_relative:
194-
pattern = bpy.path.abspath(pattern)
194+
pattern = bpy.path.abspath(pattern, start=scene.BSEQ.root_path)
195195
# in case the blender file was created on windows system, but opened in linux system
196196
pattern = bpy.path.native_pathsep(pattern)
197197
fs = fileseq.FileSequence(pattern)

bseq/operators.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def execute(self, context):
4141
show_message_box(traceback.format_exc(), "Can't find sequence: " + str(fs), "ERROR")
4242
return {"CANCELLED"}
4343

44-
create_obj(fs, importer_prop.relative)
44+
create_obj(fs, importer_prop.relative, importer_prop.root_path)
4545
return {"FINISHED"}
4646

4747

@@ -270,6 +270,30 @@ 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-
refresh_obj(obj)
273+
refresh_obj(obj, scene)
274274

275275
return {"FINISHED"}
276+
277+
class BSEQ_OT_disable_all(bpy.types.Operator):
278+
'''This operator disable all selected sequence'''
279+
bl_label = "Disable All Sequences"
280+
bl_idname = "bseq.disableall"
281+
bl_options = {"UNDO"}
282+
283+
def execute(self, context):
284+
for obj in bpy.context.scene.collection.all_objects:
285+
if obj.BSEQ.init and obj.BSEQ.enabled:
286+
obj.BSEQ.enabled = False
287+
return {"FINISHED"}
288+
289+
class BSEQ_OT_enable_all(bpy.types.Operator):
290+
'''This operator enable all selected sequence'''
291+
bl_label = "Enable All Sequences"
292+
bl_idname = "bseq.enableall"
293+
bl_options = {"UNDO"}
294+
295+
def execute(self, context):
296+
for obj in bpy.context.scene.collection.all_objects:
297+
if obj.BSEQ.init and not obj.BSEQ.enabled:
298+
obj.BSEQ.enabled = True
299+
return {"FINISHED"}

bseq/panels.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def draw(self, context):
7474
row.operator("bseq.enableselected", text="Enable Selected")
7575
row.operator("bseq.disableselected", text="Disable Selected")
7676
row.operator("bseq.refresh", text="Refresh")
77+
row = layout.row()
78+
row.operator("bseq.enableall", text="Enable All")
79+
row.operator("bseq.disableall", text="Disable All")
80+
7781

7882

7983
class BSEQ_Settings(bpy.types.Panel):
@@ -192,6 +196,10 @@ def draw(self, context):
192196
col1.label(text="Use Relative Path")
193197
col2.prop(importer_prop, "relative", text="")
194198

199+
if importer_prop.relative is True:
200+
col1.label(text="Root Directory")
201+
col2.prop(importer_prop, "root_path", text="")
202+
195203
layout.operator("sequence.load")
196204
split = layout.split()
197205
col1 = split.column()

bseq/properties.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ class BSEQ_scene_property(bpy.types.PropertyGroup):
88
description="You need to go to the folder with the sequence, then click \"Accept\". ",
99
update=update_path)
1010
relative: bpy.props.BoolProperty(name='Use relative path', description="whether or not to use reletive path", default=False)
11+
root_path: bpy.props.StringProperty(name="Root Directory",
12+
subtype="DIR_PATH",
13+
description="Select a root folder for all relative paths. When not set the current filename is used.",
14+
update=update_path)
1115
fileseq: bpy.props.EnumProperty(
1216
name="File Sequences",
1317
description="Please choose the file sequences you want",

bseq/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ def stop_animation():
2626

2727

2828

29-
def refresh_obj(obj):
29+
def refresh_obj(obj, scene):
3030
fs = obj.BSEQ.pattern
3131
if obj.BSEQ.use_relative:
32-
fs = bpy.path.abspath(fs)
32+
fs = bpy.path.abspath(fs, start=scene.BSEQ.root_path)
3333
fs = fileseq.findSequenceOnDisk(fs)
3434
fs = fileseq.findSequenceOnDisk(fs.dirname() + fs.basename() + "@" + fs.extension())
3535
fs = str(fs)
3636
if obj.BSEQ.use_relative:
37-
fs = bpy.path.relpath(fs)
37+
fs = bpy.path.relpath(fs, start=scene.BSEQ.root_path)
3838
obj.BSEQ.pattern = fs

0 commit comments

Comments
 (0)