[Durian-svn] [7293] updates to colins scripts
campbell
institute at blender.org
Sun Jul 18 16:15:31 CEST 2010
Revision: 7293
https://blenderinstitute.dyndns.org/durian-svn/?do=log&project=durian&path=/&rev=7293
Author: campbell
Date: 2010-07-18 16:15:30 +0200 (Sun, 18 Jul 2010)
Log Message:
-----------
updates to colins scripts
Modified Paths:
--------------
pro/scripts/op/sequencer_utils/__init__.py
pro/scripts/op/sequencer_utils/size_mismatch.py
pro/scripts/op/sequencer_utils/switch_finals.py
Added Paths:
-----------
pro/scripts/op/sequencer_utils/auto_namer.py
pro/scripts/op/sequencer_utils/length_set.py
Modified: pro/scripts/op/sequencer_utils/__init__.py
===================================================================
--- pro/scripts/op/sequencer_utils/__init__.py 2010-07-18 13:29:40 UTC (rev 7292)
+++ pro/scripts/op/sequencer_utils/__init__.py 2010-07-18 14:15:30 UTC (rev 7293)
@@ -1,55 +1,71 @@
+import bpy
import space_sequencer
-def colins_report(data):
+
+def colins_report(self, data):
+ data = data.strip()
+ '''
+ textblock = bpy.data.texts.get("seq_report.log")
+ if not textblock:
+ textblock = bpy.data.texts.new("seq_report.log")
+
+ textblock.from_string(data)
+
+ for screen in bpy.data.screens:
+ for area in screen.areas:
+ for space in area.spaces:
+ if type(space) == bpy.types.SpaceTextEditor:
+ space.text = textblock
+ '''
-
+ for l in data.split("\n"):
+ self.report('INFO', l)
+
-class SizeMismatchImages(bpy.types.Operator):
+
+class SeqGeneric(bpy.types.Operator):
''''''
- bl_idname = "sequencer.size_mismatch_images"
- bl_label = "Sel Images Different to Render Size"
+ bl_idname = "sequencer.generic"
+ bl_label = "_Generic_Seq_Tool"
+ bl_options = {'UNDO'}
+ module = bpy.props.StringProperty(name="Module", description="Module name of the addon to expand")
+
def execute(self, context):
- import size_mismatch_select
- errors = size_mismatch_select.main(context)
- colins_report(errors)
+ mod_name = self.properties.module.split(".")
+ mod_name, mod_func = mod_name[0], "main" if len(mod_name) == 1 else mod_name[1]
+ exec("import %s; reload(%s); colins_report(self, %s.%s())" % (mod_name, mod_name, mod_name, mod_func))
return {'FINISHED'}
-class SwitchFinals(bpy.types.Operator):
- ''''''
- bl_idname = "sequencer.switch_finals"
- bl_label = "Switch Finals"
+class SEQUENCER_MT_durian(bpy.types.Menu):
+ bl_label = "DurianStuff"
- def execute(self, context):
- import switch_finals
- errors = switch_finals.main(context)
- colins_report(errors)
- return {'FINISHED'}
+ def draw(self, context):
+ layout = self.layout
-def menu_func_switch_finals(self, context):
- self.layout.operator("sequencer.switch_finals")
+ layout.operator("sequencer.generic", text="Switch Finals (JPEG)").module = "switch_finals.main_jpg"
+ layout.operator("sequencer.generic", text="Switch Finals (EXR)").module = "switch_finals.main_exr"
+ layout.operator("sequencer.generic", text="Select Non-Render Images").module = "size_mismatch"
+ layout.operator("sequencer.generic", text="Auto Strip Namer").module = "auto_namer"
+ layout.operator("sequencer.generic", text="Set Active Length").module = "length_set"
-def menu_func_size_mismatch(self, context):
- self.layout.operator("sequencer.size_mismatch_images")
+def menu_func(self, context):
+ self.layout.menu("SEQUENCER_MT_durian")
+
+
def register():
- bpy.types.register(SizeMismatchImages)
- bpy.types.register(SwitchFinals)
- bpy.types.SEQUENCER_HT_header.append(menu_func_switch_finals)
- bpy.types.SEQUENCER_HT_header.append(menu_func_size_mismatch)
+ bpy.types.register(SeqGeneric)
+ bpy.types.register(SEQUENCER_MT_durian)
+ bpy.types.SEQUENCER_HT_header.append(menu_func)
def unregister():
- bpy.types.unregister(SizeMismatchImages)
- bpy.types.unregister(SwitchFinals)
- bpy.types.SEQUENCER_HT_header.remove(menu_func_switch_finals)
- bpy.types.SEQUENCER_HT_header.remove(menu_func_size_mismatch)
+ bpy.types.unregister(SeqGeneric)
+ bpy.types.unregister(SEQUENCER_MT_durian)
+ bpy.types.SEQUENCER_HT_header.remove(menu_func)
- # bpy.types.unregister(PadFrames)
- # bpy.types.SEQUENCER_MT_strip.remove(menu_func_pad)
- # bpy.types.SEQUENCER_HT_header.remove(menu_func)
-
'''
if __name__ == "__main__":
register()
Added: pro/scripts/op/sequencer_utils/auto_namer.py
===================================================================
--- pro/scripts/op/sequencer_utils/auto_namer.py (rev 0)
+++ pro/scripts/op/sequencer_utils/auto_namer.py 2010-07-18 14:15:30 UTC (rev 7293)
@@ -0,0 +1,35 @@
+import bpy
+import os
+
+def main():
+ seqs = []
+ for seq in bpy.context.selected_sequences:
+ if seq.type in ('MOVIE', 'SOUND'):
+ name = os.path.splitext(os.path.basename(seq.filepath))[0]
+ seqs.append((seq, name))
+ elif seq.type == 'IMAGE':
+ name = os.path.splitext(seq.getStripElem(seq.frame_start).filename)[0]
+ seqs.append((seq, name))
+
+
+
+ seqs.sort(key=lambda seq: seq[0].frame_final_start)
+ message = ["Rename Images:"]
+ for seq, name in seqs:
+ name_new = name
+
+ seq.name = "~temp~"
+
+ i = 1
+ while name_new in bpy.context.scene.sequence_editor.sequences_all:
+ name_new = name + (".%.3d" % i)
+ i += 1
+
+ seq.name = name_new
+
+ if name != name_new:
+ message.append(" rename: %s --> %s" % (name, name_new))
+
+
+ return "\n".join(message)
+
Added: pro/scripts/op/sequencer_utils/length_set.py
===================================================================
--- pro/scripts/op/sequencer_utils/length_set.py (rev 0)
+++ pro/scripts/op/sequencer_utils/length_set.py 2010-07-18 14:15:30 UTC (rev 7293)
@@ -0,0 +1,23 @@
+import bpy
+import os
+
+def main():
+
+ seqs = bpy.context.selected_sequences
+ seqs.sort(key=lambda seq: seq.frame_final_start)
+ seq_act = bpy.context.scene.sequence_editor.active_strip
+ length = seq_act.frame_final_end - seq_act.frame_final_start
+
+ tot_diff = 0
+ for seq in seqs:
+ length_iter = seq.frame_final_end - seq.frame_final_start
+ diff = length - length_iter
+
+ if tot_diff:
+ seq.frame_start += tot_diff
+
+ if diff:
+ seq.frame_final_end = seq.frame_final_start + length
+ tot_diff += diff
+
+ return ""
Modified: pro/scripts/op/sequencer_utils/size_mismatch.py
===================================================================
--- pro/scripts/op/sequencer_utils/size_mismatch.py 2010-07-18 13:29:40 UTC (rev 7292)
+++ pro/scripts/op/sequencer_utils/size_mismatch.py 2010-07-18 14:15:30 UTC (rev 7293)
@@ -58,7 +58,7 @@
elems = [elem for elem in elems if elem]
for elem in elems:
filepath = os.path.join(directory, elem.filename)
- print("\t" + filepath)
+ print(" " + filepath)
if not os.path.exists(filepath):
errors.append(" ".join([seq.name, "frame:", str(seq.frame_final_start), "missing:", filepath]))
@@ -71,12 +71,15 @@
if DO_QUICKY:
break
+ if not seqs:
+ return "No Image Strips Selected!!!"
+
data = ""
- data += ("Image Mismatch Errors:")
+ data += ("Image Mismatch Errors (See selected image strips):\n\n")
for error in errors:
- data += ("\t%s\n" % error)
+ data += (" %s\n" % error)
- return
+ return data
def main():
Modified: pro/scripts/op/sequencer_utils/switch_finals.py
===================================================================
--- pro/scripts/op/sequencer_utils/switch_finals.py 2010-07-18 13:29:40 UTC (rev 7292)
+++ pro/scripts/op/sequencer_utils/switch_finals.py 2010-07-18 14:15:30 UTC (rev 7293)
@@ -6,6 +6,7 @@
DEBUG = False
# CONSTANTS
+global IMAGE_EXT
CONTEXT = 'SEL' # SEL or ALL
IMAGE_EXT = ".exr" # .exr or .jpg
AVI_DIR = "//render/"
@@ -26,14 +27,12 @@
blend_lookup = {}
-for blend in blend_path_list(SVN_DIR):
- basename = os.path.splitext(os.path.basename(blend))[0]
- blend_lookup[basename] = blend
def convert_avi_to_exr(filepath):
'''
Takes the full avi path
'''
+
if filepath.startswith(AVI_DIR):
base_name = os.path.splitext(filepath)[0]
base_name = os.path.basename(base_name)
@@ -92,7 +91,7 @@
# print("PATH:", exr_path)
return exr_path, exrs, frame_start, frame_end
else:
- print("\texr path missing: %s" % exr_path)
+ print(" exr path missing: %s" % exr_path)
return "", [], -1, -1
@@ -117,7 +116,19 @@
def main():
if not bpy:
return
+
+ print(IMAGE_EXT)
+
+ MISSING_BLENDS[:] = [] # avis that have no blends
+ MISSING_EXRS[:] = [] # avis that have no exrs
+ MISSING_EXRS_FILES[:] = [] # avis that have no exrs
+ BAD_AVI_LENGTHS[:] = [] # blends that are not the same length as the avis
+ blend_lookup.clear()
+ for blend in blend_path_list(SVN_DIR):
+ basename = os.path.splitext(os.path.basename(blend))[0]
+ blend_lookup[basename] = blend
+
'''
a = convert_avi_to_exr("//render/04.2g_comp.avi")[0]
print(convert_exr_to_avi(a))
@@ -187,26 +198,37 @@
data += ("Missing Blends\n")
for blend in MISSING_BLENDS:
- data += ("\t" + blend + "\n")
+ data += (" " + blend + "\n")
data += ("\n")
data += ("Missing EXR's for AVI's\n")
for avi in MISSING_EXRS:
# filter out crap
if "/render/" in avi:
- data += ("\t" + avi "\n")
+ data += (" " + avi + "\n")
data += ("\n")
data += ("Missing EXR image files\n")
for f in MISSING_EXRS_FILES:
- data += ("\t" + f + "\n")
+ data += (" " + f + "\n")
data += ("\n")
data += ("Length mismatch\n")
for blend in BAD_AVI_LENGTHS:
- data += ("\t" + " ".join(blend) + "\n")
+ data += (" " + " ".join(blend) + "\n")
return data
-if __name__ == "__main__":
- main()
+def main_jpg():
+ global IMAGE_EXT
+ IMAGE_EXT = ".jpg"
+ print(IMAGE_EXT, "woo")
+ return main()
+
+def main_exr():
+ global IMAGE_EXT
+ IMAGE_EXT = ".exr"
+ return main()
+
+#if __name__ == "__main__":
+# main()
More information about the Durian-svn
mailing list