Example #1
0
def get_src_path(shot_id, project_id):
    shot = StrackGlobals.st.shot.find("id=%s" % shot_id,
                                      StrackGlobals.st.shot.fields)
    sequence_id = shot.get("sequence_id")
    shot_name = shot.get("code")
    project = StrackGlobals.st.project.find("id=%s" % project_id)
    project_name = project.get("code")

    if sequence_id:
        sequence = StrackGlobals.st.sequence.find("id={}".format(sequence_id))
        sequence_name = sequence.get("code")
    else:
        sequence_name = ""

    version_path = ''
    # get format path
    format_dir = "elements/processed/format"
    format_path = os.path.normpath(
        os.path.join(project_name, "sequences", sequence_name, shot_name,
                     format_dir))
    format_full_path = os.path.join(
        get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
        format_path)
    if os.path.exists(format_full_path):
        versions = os.listdir(format_full_path)
        versions.sort(key=lambda x: int(x.split("v")[-1]))
        the_latest_version = versions[-1]
        version_path = os.path.join(format_full_path, the_latest_version)
        # nuke.message("from the reformat")
    # get retime path
    if not version_path:
        retime_dir = "elements/processed/retime"
        retime_path = os.path.normpath(
            os.path.join(project_name, "sequences", sequence_name, shot_name,
                         retime_dir))
        retime_full_path = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            retime_path)
        if os.path.exists(retime_full_path):
            versions = os.listdir(retime_full_path)
            versions.sort(key=lambda x: int(x.split("v")[-1]))
            the_latest_version = versions[-1]
            version_path = os.path.join(retime_full_path, the_latest_version)
            # nuke.message("from the retime")
    # get the iplate path
    if not version_path:
        iplate_dir = "elements/iplate"
        iplate_path = os.path.normpath(
            os.path.join(project_name, "sequences", sequence_name, shot_name,
                         iplate_dir))
        full_path = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            iplate_path)
        versions = os.listdir(full_path)
        versions.sort(key=lambda x: int(x.split("v")[-1]))
        try:
            the_latest_version = versions[-1]
            version_path = os.path.join(full_path, the_latest_version)
            # nuke.message("from the iplate")
        except:
            nuke.message("no resource")
    return version_path
Example #2
0
def main():
    #get the task
    item = StrackGlobals.selected_task.get('item')

    #gether the basic info about shot,seq,project
    task_id = StrackGlobals.selected_task.get("id")
    item_id = item.get('item_id')
    project_id = item.get("p_id")
    item_type = item.get('type')

    shot = StrackGlobals.st.shot.find("id=%s" % item_id,
                                      StrackGlobals.st.shot.fields)
    sequence_id = shot.get("sequence_id")
    shot_name = shot.get("code")
    project = StrackGlobals.st.project.find("id=%s" % project_id)
    project_name = project.get("code")
    task_name = StrackGlobals.st.task.find("id={}".format(task_id)).get("code")
    user_id = StrackGlobals.st.task.find(
        "id={}".format(task_id)).get("assignee")
    user_name = str(
        StrackGlobals.st.user.find("id={}".format(user_id)).get("name"))

    if sequence_id:
        sequence = StrackGlobals.st.sequence.find("id={}".format(sequence_id))
        sequence_name = sequence.get("code")
    else:
        sequence_name = ""

    #get the shot info
    try:
        retime = float(shot.get("retime"))
    except:
        retime = "-"
    print(retime)

    #get the tracking info
    # track_step = StrackGlobals.st.step.find("code=tracking")
    # print(item,item_id,item_type,track_step)
    version_path = ''
    #get format path
    format_dir = "elements/processed/format"
    format_path = os.path.normpath(
        os.path.join(project_name, "sequences", sequence_name, shot_name,
                     format_dir))
    format_full_path = os.path.join(
        get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
        format_path)
    if os.path.exists(format_full_path):
        print(format_full_path, 444444444444)
        versions = os.listdir(format_full_path)
        versions.sort(key=lambda x: int(x.split("v")[-1]))
        print(versions, "**********************************")
        the_latest_version = versions[-1]
        version_path = os.path.join(format_full_path, the_latest_version)
        nuke.message("from the reformat")
    #get retime path
    if not version_path:
        retime_dir = "elements/processed/retime"
        retime_path = os.path.normpath(
            os.path.join(project_name, "sequences", sequence_name, shot_name,
                         retime_dir))
        retime_full_path = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            retime_path)
        if os.path.exists(retime_full_path):
            print(retime_full_path, 444444444444)
            versions = os.listdir(retime_full_path)
            versions.sort(key=lambda x: int(x.split("v")[-1]))
            print(versions, "**********************************")
            the_latest_version = versions[-1]
            version_path = os.path.join(retime_full_path, the_latest_version)
            print version_path
            nuke.message("from the retime")
    #get the iplate path
    if not version_path:
        iplate_dir = "elements/iplate"
        iplate_path = os.path.normpath(
            os.path.join(project_name, "sequences", sequence_name, shot_name,
                         iplate_dir))
        full_path = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            iplate_path)
        print(full_path, 6666666666666666666666666666666666666666666666)
        versions = os.listdir(full_path)
        versions.sort(key=lambda x: int(x.split("v")[-1]))
        print(versions, "**********************************")
        try:
            the_latest_version = versions[-1]
            version_path = os.path.join(full_path, the_latest_version)
            nuke.message("from the iplate")
        except:
            nuke.message("no resource")
            return

    read_source = nuke.getFileNameList(version_path)[0]
    print('read source path %s' % read_source)
    readfile = nuke.createNode("Read")
    read_path = os.path.join(version_path, read_source)
    readfile['file'].fromUserText(read_path)

    output_name = shot_name + "_tracking_" + user_name + "_v01"
    render_path = os.path.join(project_name, "sequences", sequence_name,
                               shot_name, "work/tracking", task_name,
                               "sourceimages", output_name,
                               (output_name + ".%04d.jpg"))
    writepath = os.path.join(
        get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
        render_path)
    writepath = writepath.replace("\\", "/")
    print writepath, "-----3333333333333333333333333333333333333333333333333333333333333333333333"
    writenode = nuke.createNode("Write")
    writenode["file_type"].setValue("jpeg")
    writenode["_jpeg_quality"].setValue(1)
    writenode["file"].setValue(writepath)
    render_dir = os.path.dirname(writepath)
    writenode["beforeRender"].setValue(
        "import os\nif not os.path.exists(r'%s'):\n    os.mkdir(r'%s') " %
        (render_dir, render_dir))

    print("---------------------------------pending")
    if retime != 1 and isinstance(retime, float):
        lastframe = readfile["last"].getValue()
        frames = lastframe - 1000
        retime_value = frames / retime + 1000
        print("-----------------------------%s" % retime_value)
        try:
            oflow = nuke.createNode("OFlow2")
        except:
            oflow = nuke.createNode("OFlow")
        oflow.setInput(0, readfile)
        oflow["interpolation"].setValue(0)
        oflow["timing2"].setValue(2)
        oflow["timingFrame2"].setAnimated(0)
        oflow["input.first"].setValue(1001)
        oflow["input.last"].setValue(lastframe)
        oflow_attr = oflow["timingFrame2"].animations()[0]
        oflow_attr.setKey(1001, 1001)
        oflow_attr.setKey(retime_value, lastframe)
        writenode.setInput(0, oflow)
    else:
        retime_value = readfile["last"].getValue()
        writenode.setInput(0, readfile)

    nuke.root()["fps"].setValue(25)
    nuke.root()["first_frame"].setValue(1001)
    nuke.root()["last_frame"].setValue(retime_value)

    return
Example #3
0
def main():
    user = StrackGlobals.me
    user_name = user.get("name")

    path_judge = nuke.ask("是否为检修?")
    key_word = nuke.getInput("分割值")
    if not key_word:
        key_word = "_paint_"
    if path_judge:
        print "hahaha"
        shot_list = []
        new_nodes = []
        shot_dict = {}
        for writenode in nuke.allNodes("Write"):
            if key_word in writenode["file"].getValue():
                shot_name = os.path.basename(
                    writenode["file"].getValue()).split(key_word)[0]
                shot_list.append(shot_name)
                shot_dict[shot_name] = writenode
        print shot_list
        if not shot_list:
            nuke.message("没有产生镜头列表,操作结束。")
            return
        viewpath = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            StrackGlobals.current_project.get("code"), "global/ooh")
        print(viewpath)
        dir_widget = dir_locate(viewpath)
        src_path = dir_widget.return_dir()
        if src_path and os.path.isdir(src_path):
            file_candidates = nuke.getFileNameList(src_path)
            for file_ooh in file_candidates:
                file_ooh_fullpath = os.path.join(src_path, file_ooh)
                ooh_shot_name = file_ooh.split(key_word)[0]
                if os.path.isdir(file_ooh_fullpath):
                    continue
                else:
                    ooh_readnode = nuke.createNode("Read")
                    ooh_readnode['file'].fromUserText(file_ooh_fullpath)
                    ooh_readnode["disable"].setValue(1)
                    tar_node = shot_dict.get(ooh_shot_name)
                    if not tar_node:
                        new_nodes.append(ooh_readnode)
                        continue
                    ooh_readnode.setXpos(tar_node.xpos())
                    ooh_readnode.setYpos(tar_node.ypos() + 300)
                    print(new_nodes)
        value = nuke.getInput("每行个数")
        func_deal(new_nodes,
                  user_name,
                  int(value),
                  count=1,
                  x_dist=-800,
                  y_dist=0,
                  check=True,
                  key_word=key_word)
        return
    else:
        pass

    #先进行自选导入。如果跳过,则直接处理场景内的文件。
    file_path = True
    while file_path:
        viewpath = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            StrackGlobals.current_project.get("code"), "global/ooh")
        print(viewpath)
        dir_widget = dir_locate(viewpath)
        src_path = dir_widget.return_dir()
        if src_path and os.path.isdir(src_path):
            file_candidates = nuke.getFileNameList(src_path)
            for file_ooh in file_candidates:
                file_ooh_fullpath = os.path.join(src_path, file_ooh)
                if os.path.isdir(file_ooh_fullpath):
                    continue
                else:
                    ooh_readnode = nuke.createNode("Read")
                    ooh_readnode['file'].fromUserText(file_ooh_fullpath)
                    ooh_readnode["disable"].setValue(1)
            file_path = False
        else:
            path_judge = nuke.ask("没有查找路径,将处理工程中文件,是否继续?")
            if path_judge:
                file_path = False
            else:
                return
    all_read_nodes = nuke.allNodes("Read")
    all_read_nodes.sort(key=lambda x: x["file"].getValue())

    value = nuke.getInput("每行个数")
    try:
        int_value = int(value)
    except:
        answer = nuke.ask("未输入每行个数,默认100,是否继续?")
        if answer:
            int_value = 100
        else:
            return
    func_deal(all_read_nodes,
              user_name,
              int_value,
              count=1,
              x_dist=0,
              y_dist=0,
              key_word=key_word)
Example #4
0
def func_deal(all_read_nodes,
              user_name,
              int_value=100,
              count=1,
              x_dist=0,
              y_dist=0,
              check=False,
              key_word="_paint_"):
    for readnode in all_read_nodes:
        input_file_path = readnode["file"].getValue()
        input_file_name = os.path.basename(input_file_path)
        file_name = os.path.splitext(input_file_name)[0]
        if key_word not in file_name:
            continue
        #所有项目都可以用的前提是,外包方100%遵守规范
        shot_name = file_name.split(key_word)[0]
        shot = st.shot.find("code = %s" % shot_name,
                            StrackGlobals.st.shot.fields)
        if not shot:
            nuke.message("镜头不存在:%s" % shot_name)
            continue
        project_id = shot.get("project_id")
        sequence_id = shot.get("sequence_id")

        project = StrackGlobals.st.project.find("id=%s" % project_id)
        project_name = project.get("code")

        epi_name = ""
        if sequence_id:
            sequence = StrackGlobals.st.sequence.find(
                "id={}".format(sequence_id))
            sequence_name = sequence.get("code")
            epi_id = StrackGlobals.st.sequence.find(
                "id={}".format(sequence_id), ["episode_id"]).get("episode_id")
            if epi_id:
                epi_name = StrackGlobals.st.episode.find("id=%s" %
                                                         epi_id).get("code")
        else:
            sequence_name = ""
            epi_name = ""

        input_file_dir = os.path.dirname(input_file_path)
        print(input_file_path)
        if platform.system() == "Linux":
            date_name = input_file_dir.split("/")[7]
        else:
            date_name = input_file_dir.split("/")[6]
        output_dir = input_file_path.split(date_name)[0]
        output_path = os.path.normpath(
            os.path.join(output_dir, "reference", date_name, user_name,
                         "{}.%04d.jpeg".format(file_name))).replace("\\", "/")
        print(output_path)
        readnode.setXpos(x_dist)
        readnode.setYpos(y_dist)

        write_node = nuke.createNode("Write")
        write_node['file'].setValue(output_path)
        write_node["file_type"].setValue("jpeg")
        write_node.setInput(0, readnode)
        write_node.setXpos(x_dist)
        write_node.setYpos(y_dist + 200)

        version_path = ''
        # get format path
        format_dir = "elements/processed/reformat"
        format_path = os.path.normpath(
            os.path.join(project_name, epi_name, "sequences", sequence_name,
                         shot_name, format_dir))
        format_full_path = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            format_path)
        if os.path.exists(format_full_path):
            try:
                versions = os.listdir(format_full_path)
                versions.sort(key=lambda x: int(x.split("v")[-1]))
                the_latest_version = versions[-1]
                version_path = os.path.join(format_full_path,
                                            the_latest_version)
            except:
                nuke.message("%s: reformat错误!!!!" % shot_name)
        # get retime path
        if not version_path:
            retime_dir = "elements/processed/retime"
            retime_path = os.path.normpath(
                os.path.join(project_name, epi_name, "sequences",
                             sequence_name, shot_name, retime_dir))
            retime_full_path = os.path.join(
                get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
                retime_path)
            if os.path.exists(retime_full_path):
                try:
                    versions = os.listdir(retime_full_path)
                    versions.sort(key=lambda x: int(x.split("v")[-1]))
                    the_latest_version = versions[-1]
                    version_path = os.path.join(retime_full_path,
                                                the_latest_version)
                except:
                    nuke.message("%s :retime错误!!!!" % shot_name)
        # get the iplate path
        if not version_path:
            iplate_dir = "elements/iplate"
            iplate_path = os.path.normpath(
                os.path.join(project_name, epi_name, "sequences",
                             sequence_name, shot_name, iplate_dir))
            full_path = os.path.join(
                get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
                iplate_path)
            versions = os.listdir(full_path)
            versions.sort(key=lambda x: int(x.split("v")[-1]))
            try:
                the_latest_version = versions[-1]
                version_path = os.path.join(full_path, the_latest_version)
            except:
                nuke.message("%s :no resource" % shot_name)
                continue
        read_source = nuke.getFileNameList(version_path)[0]
        readfile = nuke.createNode("Read")
        read_path = os.path.join(version_path, read_source)
        readfile['file'].fromUserText(read_path)
        readfile["frame_mode"].setValue(1)
        readfile["frame"].setValue("1")

        readfile.setXpos(x_dist)
        readfile.setYpos(y_dist - 150)
        readfile["disable"].setValue(1)

        if count < int_value:
            if check:
                x_dist -= 150
            else:
                x_dist += 150
        else:
            y_dist += 1000
            x_dist = 0
            count = 0
        count += 1
    return nuke.message("Done!!!")
Example #5
0
def main():
    #get the task
    item = StrackGlobals.selected_task.get('item')

    #gether the basic info about shot,seq,project
    task_id = StrackGlobals.selected_task.get("id")
    item_id = item.get('item_id')
    project_id = item.get("p_id")
    item_type = item.get('type')

    shot = StrackGlobals.st.shot.find("id=%s" % item_id,
                                      StrackGlobals.st.shot.fields)
    sequence_id = shot.get("sequence_id")
    shot_name = shot.get("code")
    project = StrackGlobals.st.project.find("id=%s" % project_id)
    project_name = project.get("code")
    task_name = StrackGlobals.st.task.find("id={}".format(task_id)).get("code")
    user_id = StrackGlobals.st.task.find(
        "id={}".format(task_id)).get("assignee")
    user_name = str(
        StrackGlobals.st.user.find("id={}".format(user_id)).get("name"))

    if sequence_id:
        sequence = StrackGlobals.st.sequence.find("id={}".format(sequence_id))
        sequence_name = sequence.get("code")
    else:
        sequence_name = ""

    root = get_root_dir(StrackGlobals.st, StrackGlobals.current_project)
    root_output = 'o:\\'
    #get the tracking info
    version_path = ''
    #get format path
    format_dir = "elements/processed/format"
    format_path = os.path.normpath(
        os.path.join(project_name, "sequences", sequence_name, shot_name,
                     format_dir))
    format_full_path = os.path.join(root, format_path)
    if os.path.exists(format_full_path):
        try:
            versions = os.listdir(format_full_path)
            versions.sort(key=lambda x: int(x.split("v")[-1]))
            the_latest_version = versions[-1]
            version_path = os.path.join(format_full_path, the_latest_version)
            nuke.message("from the reformat")
        except:
            nuke.message(u"reformat错误!!!!")
    #get retime path
    if not version_path:
        retime_dir = "elements/processed/retime"
        retime_path = os.path.normpath(
            os.path.join(project_name, "sequences", sequence_name, shot_name,
                         retime_dir))
        retime_full_path = os.path.join(root, retime_path)
        if os.path.exists(retime_full_path):
            try:
                versions = os.listdir(retime_full_path)
                versions.sort(key=lambda x: int(x.split("v")[-1]))
                the_latest_version = versions[-1]
                version_path = os.path.join(retime_full_path,
                                            the_latest_version)
                nuke.message("from the retime")
            except:
                nuke.message(u"retime错误!!!!")
    #get the iplate path
    if not version_path:
        iplate_dir = "elements/iplate"
        iplate_path = os.path.normpath(
            os.path.join(project_name, "sequences", sequence_name, shot_name,
                         iplate_dir))
        full_path = os.path.join(root, iplate_path)
        versions = os.listdir(full_path)
        versions.sort(key=lambda x: int(x.split("v")[-1]))
        try:
            the_latest_version = versions[-1]
            version_path = os.path.join(full_path, the_latest_version)
            nuke.message("from the iplate")
        except:
            nuke.message("no resource")
            return

    read_source = nuke.getFileNameList(version_path)[0]
    print('read source path %s' % read_source)
    readfile = nuke.createNode("Read")
    read_path = os.path.join(version_path, read_source)
    readfile['file'].fromUserText(read_path)

    output_name = shot_name + "_tracking_" + user_name + "_v01"
    render_path = os.path.join(project_name, "sequences", sequence_name,
                               shot_name, "work/tracking", task_name,
                               "sourceimages", output_name,
                               (output_name + ".%04d.jpg"))
    writepath = os.path.join(root_output, render_path)
    writepath = writepath.replace("\\", "/")
    writenode = nuke.createNode("Write")
    writenode["file_type"].setValue("jpeg")
    writenode["_jpeg_quality"].setValue(1)
    writenode["file"].setValue(writepath)
    render_dir = os.path.dirname(writepath)
    writenode["beforeRender"].setValue(
        "import os\nif not os.path.exists(r'%s'):\n    os.mkdir(r'%s') " %
        (render_dir, render_dir))
    retime_value = readfile["last"].getValue()
    nuke.root()["fps"].setValue(25)
    nuke.root()["first_frame"].setValue(1001)
    nuke.root()["last_frame"].setValue(retime_value)

    return
Example #6
0
def main():
    error_list = []
    csv_file = dir_locate().return_dir()
    print
    csv_file
    if not os.path.isfile(csv_file):
        return
    shot_list = []

    with open(csv_file, mode='r') as infile:
        reader = csv.reader(infile)
        for rows in reader:
            try:
                print(rows[0])
                shot_list.append(rows[0].strip())
            except:
                continue

    value = nuke.getInput("每行个数")
    try:
        int_value = int(value)
    except:
        if nuke.ask("未输入每行个数,默认100,是否继续?"):
            int_value = 100
        else:
            return
    count = 1
    x_dist = 0
    y_dist = 0
    for shot_name in shot_list:
        shot = st.shot.find("code = %s" % shot_name,
                            StrackGlobals.st.shot.fields)
        if not shot:
            error_list.append(shot_name)
            continue
        project_id = shot.get("project_id")
        sequence_id = shot.get("sequence_id")

        project = StrackGlobals.st.project.find("id=%s" % project_id)
        project_name = project.get("code")

        epi_name = ""
        if sequence_id:
            sequence = StrackGlobals.st.sequence.find(
                "id={}".format(sequence_id))
            sequence_name = sequence.get("code")
            epi_id = StrackGlobals.st.sequence.find(
                "id={}".format(sequence_id), ["episode_id"]).get("episode_id")
            if epi_id:
                epi_name = StrackGlobals.st.episode.find("id=%s" %
                                                         epi_id).get("code")
        else:
            sequence_name = ""
            epi_name = ""

        version_path = ''
        # get format path
        format_dir = "elements/processed/reformat"
        format_path = os.path.normpath(
            os.path.join(project_name, epi_name, "sequences", sequence_name,
                         shot_name, format_dir))
        format_full_path = os.path.join(
            get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
            format_path)
        if os.path.exists(format_full_path):
            try:
                versions = os.listdir(format_full_path)
                versions.sort(key=lambda x: int(x.split("v")[-1]))
                the_latest_version = versions[-1]
                version_path = os.path.join(format_full_path,
                                            the_latest_version)
            except:
                nuke.message("%s: reformat错误!!!!" % shot_name)
        # get retime path
        if not version_path:
            retime_dir = "elements/processed/retime"
            retime_path = os.path.normpath(
                os.path.join(project_name, epi_name, "sequences",
                             sequence_name, shot_name, retime_dir))
            retime_full_path = os.path.join(
                get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
                retime_path)
            if os.path.exists(retime_full_path):
                try:
                    versions = os.listdir(retime_full_path)
                    versions.sort(key=lambda x: int(x.split("v")[-1]))
                    the_latest_version = versions[-1]
                    version_path = os.path.join(retime_full_path,
                                                the_latest_version)
                except:
                    nuke.message("%s :retime错误!!!!" % shot_name)
        # get the iplate path
        if not version_path:
            iplate_dir = "elements/iplate"
            iplate_path = os.path.normpath(
                os.path.join(project_name, epi_name, "sequences",
                             sequence_name, shot_name, iplate_dir))
            full_path = os.path.join(
                get_root_dir(StrackGlobals.st, StrackGlobals.current_project),
                iplate_path)
            versions = os.listdir(full_path)
            versions.sort(key=lambda x: int(x.split("v")[-1]))
            try:
                the_latest_version = versions[-1]
                version_path = os.path.join(full_path, the_latest_version)
            except:
                nuke.message("%s :no resource" % shot_name)
                continue
        print(version_path)
        read_source = nuke.getFileNameList(version_path)[0]
        readfile = nuke.createNode("Read")
        read_path = os.path.join(version_path, read_source)
        readfile['file'].fromUserText(read_path)

        readfile.setXpos(x_dist)
        readfile.setYpos(y_dist - 150)
        readfile["disable"].setValue(1)

        if count < int_value:
            x_dist += 200
        else:
            y_dist += 450
            x_dist = 0
            count = 0
        count += 1
    nuke.message("Done!!!")
    return nuke.message(str(error_list))