コード例 #1
0
 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"}
コード例 #2
0
    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"}