def main(argv): options, args = process_args() renderchan = RenderChan() renderchan.projects.readonly = True if options.profile: renderchan.setProfile(options.profile) if options.stereo in ("left","l"): renderchan.setStereoMode("left") elif options.stereo in ("right","r"): renderchan.setStereoMode("right") if options.active_project: renderchan.projects.load(options.active_project) if options.compare_time: compare_time=float(options.compare_time) else: compare_time=None if not ( options.action and options.action in ['render','merge','snapshot'] ): options.action = 'render' if options.action != 'snapshot': taskfile = RenderChanFile(options.filename, renderchan.modules, renderchan.projects) taskfile.setFormat(options.format) if options.action == 'merge' and options.stereo and ( options.stereo[0:1]=="v" or options.stereo[0:1]=="h" ): pass else: (isDirty, tasklist, maxTime)=renderchan.parseDirectDependency(taskfile, compare_time) if isDirty: print("ERROR: There are unrendered dependencies for this file!", file=sys.stderr) print(" (Project tree changed or job started too early?)", file=sys.stderr) print(" Aborting.", file=sys.stderr) exit(1) if options.action == 'render': if options.start and options.end: renderchan.job_render(taskfile, taskfile.getFormat(), updateCompletion, int(options.start), int(options.end), compare_time) else: renderchan.job_render(taskfile, taskfile.getFormat(), updateCompletion, compare_time) elif options.action == 'merge': if options.stereo and ( options.stereo[0:1]=="v" or options.stereo[0:1]=="h" ): renderchan.job_merge_stereo(taskfile, options.stereo) else: renderchan.job_merge(taskfile, taskfile.getFormat(), renderchan.projects.stereo, compare_time) elif options.action == 'snapshot': if not options.snapshot_target: print("ERROR: Please specify output filename using --target-dir option.", file=sys.stderr) renderchan.job_snapshot(options.filename, os.path.abspath(options.snapshot_target))
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"}
def main(argv): options, args = process_args() renderchan = RenderChan() renderchan.projects.readonly = True if options.profile: renderchan.setProfile(options.profile) if options.stereo in ("left", "l"): renderchan.setStereoMode("left") elif options.stereo in ("right", "r"): renderchan.setStereoMode("right") if options.active_project: renderchan.projects.load(options.active_project) if options.compare_time: compare_time = float(options.compare_time) else: compare_time = None if not (options.action and options.action in ['render', 'merge', 'snapshot']): options.action = 'render' if options.action != 'snapshot': taskfile = RenderChanFile(options.filename, renderchan.modules, renderchan.projects) taskfile.setFormat(options.format) if options.action == 'merge' and options.stereo and ( options.stereo[0:1] == "v" or options.stereo[0:1] == "h"): pass else: (isDirty, tasklist, maxTime) = renderchan.parseDirectDependency( taskfile, compare_time) if isDirty: print( "ERROR: There are unrendered dependencies for this file!", file=sys.stderr) print( " (Project tree changed or job started too early?)", file=sys.stderr) print(" Aborting.", file=sys.stderr) exit(1) if options.action == 'render': if options.start and options.end: renderchan.job_render(taskfile, taskfile.getFormat(), updateCompletion, int(options.start), int(options.end), compare_time) else: renderchan.job_render(taskfile, taskfile.getFormat(), updateCompletion, compare_time) elif options.action == 'merge': if options.stereo and (options.stereo[0:1] == "v" or options.stereo[0:1] == "h"): renderchan.job_merge_stereo(taskfile, options.stereo) else: renderchan.job_merge(taskfile, taskfile.getFormat(), renderchan.projects.stereo, compare_time) elif options.action == 'snapshot': if not options.snapshot_target: print( "ERROR: Please specify output filename using --target-dir option.", file=sys.stderr) renderchan.job_snapshot(options.filename, os.path.abspath(options.snapshot_target))