def get_renderchan_sequences(sequence): from renderchan.file import RenderChanFile sequence_list = [] if sequence.type == "IMAGE": for element in sequence.elements: path = os.path.join(bpy.path.abspath(sequence.directory), element.filename) file = RenderChanFile(path, rcl.main.modules, rcl.main.projects) if file.project != None and file.module and file.getRenderPath( ) == path: sequence_list.append(file) elif sequence.type == "MOVIE" or sequence.type == "SOUND": path = bpy.path.abspath(sequence.filepath) file = RenderChanFile(path, rcl.main.modules, rcl.main.projects) if file.project != None and file.module and file.getRenderPath( ) == path: sequence_list.append(file) elif sequence.type == "META": for subsequence in sequence.sequences: for file in get_renderchan_sequence(subsequence): is_unique = True for compare_file in sequence_list: if compare_file.getPath() == file.getPath(): is_unique = False break if is_unique: sequence_list.append(file) return sequence_list
def get_renderchan_sequences(sequence): from renderchan.file import RenderChanFile sequence_list = [] if sequence.type == "IMAGE": for element in sequence.elements: path = os.path.join(bpy.path.abspath(sequence.directory), element.filename) file = RenderChanFile(path, rcl.main.modules, rcl.main.projects) if file.project != None and file.module and file.getRenderPath() == path: sequence_list.append(file) elif sequence.type == "MOVIE" or sequence.type == "SOUND": path = bpy.path.abspath(sequence.filepath) file = RenderChanFile(path, rcl.main.modules, rcl.main.projects) if file.project != None and file.module and file.getRenderPath() == path: sequence_list.append(file) elif sequence.type == "META": for subsequence in sequence.sequences: for file in get_renderchan_sequence(subsequence): is_unique = True for compare_file in sequence_list: if compare_file.getPath() == file.getPath(): is_unique = False break if is_unique: sequence_list.append(file) return sequence_list
def execute(self, context): from renderchan.file import RenderChanFile path = bpy.path.abspath(self.properties.filepath) output = io.StringIO() with redirect_stdout(output): file = RenderChanFile(path, rcl.main.modules, rcl.main.projects) if file.project == None or not file.module: # Not a RenderChan file, just add if os.path.splitext(path)[1] in bpy.path.extensions_movie: bpy.ops.sequencer.movie_strip_add(filepath=path, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace, sound=self.sound) elif os.path.splitext(path)[1] in bpy.path.extensions_image: file_list = [] for f in self.files: file_list.append({"name": f.name}) bpy.ops.sequencer.image_strip_add(directory=os.path.dirname(bpy.path.abspath(self.filepath)), files=file_list, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace) elif os.path.splitext(path)[1] in bpy.path.extensions_audio: bpy.ops.sequencer.sound_strip_add(filepath=path, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace, cache=self.cache) else: self.report({"ERROR"}, "Could not handle this file format"); else: # It is a RenderChan file, render if necessary and then add. if file.getRenderPath() == path: path = file.getPath() render_file(file, context.scene, False) if os.path.isdir(file.getRenderPath()): file_list = [] for i in range(file.getStartFrame(), file.getEndFrame()): file_list.append({"name": "file.%05d.%s" % (i, file.getFormat())}) bpy.ops.sequencer.image_strip_add(directory=file.getRenderPath(), files=file_list, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace) elif os.path.splitext(file.getRenderPath())[1] in bpy.path.extensions_movie: bpy.ops.sequencer.movie_strip_add(filepath=file.getRenderPath(), relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace, sound=self.sound) elif os.path.splitext(file.getRenderPath())[1] in bpy.path.extensions_image: bpy.ops.sequencer.image_strip_add(directory=os.path.dirname(file.getRenderPath()), files=[{"name":os.path.basename(file.getRenderPath())}], relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace) else: self.report({"ERROR"}, "Could not handle this file format"); return {"FINISHED"}
def execute(self, context): from renderchan.file import RenderChanFile path = bpy.path.abspath(self.properties.filepath) output = io.StringIO() with redirect_stdout(output): file = RenderChanFile(path, rcl.main.modules, rcl.main.projects) if file.project == None or not file.module: # Not a RenderChan file, just add if os.path.splitext(path)[1] in bpy.path.extensions_movie: bpy.ops.sequencer.movie_strip_add(filepath=path, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace, sound=self.sound) elif os.path.splitext(path)[1] in bpy.path.extensions_image: file_list = [] for f in self.files: file_list.append({"name": f.name}) bpy.ops.sequencer.image_strip_add(directory=os.path.dirname( bpy.path.abspath(self.filepath)), files=file_list, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace) elif os.path.splitext(path)[1] in bpy.path.extensions_audio: bpy.ops.sequencer.sound_strip_add(filepath=path, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace, cache=self.cache) else: self.report({"ERROR"}, "Could not handle this file format") else: # It is a RenderChan file, render if necessary and then add. if file.getRenderPath() == path: path = file.getPath() render_file(file, context.scene, False) if os.path.isdir(file.getRenderPath()): file_list = [] for i in range(file.getStartFrame(), file.getEndFrame()): file_list.append( {"name": "file.%05d.%s" % (i, file.getFormat())}) bpy.ops.sequencer.image_strip_add( directory=file.getRenderPath(), files=file_list, relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace) elif os.path.splitext( file.getRenderPath())[1] in bpy.path.extensions_movie: bpy.ops.sequencer.movie_strip_add( filepath=file.getRenderPath(), relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace, sound=self.sound) elif os.path.splitext( file.getRenderPath())[1] in bpy.path.extensions_image: bpy.ops.sequencer.image_strip_add( directory=os.path.dirname(file.getRenderPath()), files=[{ "name": os.path.basename(file.getRenderPath()) }], relative_path=self.rel_path, frame_start=self.start, channel=self.channel, replace_sel=self.replace) else: self.report({"ERROR"}, "Could not handle this file format") return {"FINISHED"}