Beispiel #1
0
def main(file_name, local):
    logger = logging.getLogger("Hair start")
    new_file.new_file()
    # copy low mdl publish file as mdl file
    context = pipeFile.PathDetails.parse_path(file_name)
    project = context.project
    entity_type = context.entity_type
    asset_type = context.asset_type
    asset_name = context.asset_name
    # reference in mdl publish file
    asset_type_short_name = context.asset_type_short_name
    mdl_publish_file = pipeFile.get_task_publish_file(project, entity_type,
                                                      asset_type, asset_name,
                                                      "HighMdl", "HighMdl")
    if not os.path.isfile(mdl_publish_file):
        logger.warning("No mdl file published.")
        quit_maya.quit_maya()
        return
    create_reference.create_reference(mdl_publish_file)
    # create sculp group
    sculp_group = "%s_%s_SCULP" % (asset_type_short_name, asset_name)
    create_group.create_group(sculp_group)
    if local:
        create_project.create_project(os.path.dirname(file_name))
    # create project
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #2
0
 def reference(self, reference_all=False):
     items = self.get_list_view_items(self.include_list_view, reference_all)
     if not items:
         return
     reference_files = list()
     for item in items:
         publish_path = item.publish_path
         namespace = item.name if self.name_space_cbox.currentText(
         ) == "asset_name" else ":"
         reference_files.append([publish_path, namespace])
     # add progress dialog
     progress_dialog = QProgressDialog('Referencing...', 'Cancel', 0,
                                       len(reference_files))
     progress_dialog.setMinimumWidth(400)
     progress_dialog.setWindowModality(Qt.WindowModal)
     progress_dialog.show()
     for index, reference_file in enumerate(reference_files):
         progress_dialog.setValue(index)
         if progress_dialog.wasCanceled():
             break
         reference_file_path, namespace = reference_file
         if not all((reference_file_path, namespace)):
             continue
         if reference_file_path.endswith(".abc"):
             self.import_env_gpu_cache(reference_file_path, namespace)
         else:
             create_reference.create_reference(reference_file_path,
                                               namespace, True, True)
     # put char in to char group, env to env group, prop to prop group
     self.organize_type_group()
Beispiel #3
0
def rebuild_asset(context):
    asset_info_file = pipeFile.get_task_file(context.project, context.sequence,
                                             context.shot, "Anim", "Anim",
                                             "maya_shot_assetInfo", "")
    if not os.path.isfile(asset_info_file):
        log.warning("%s is not an exist file." % asset_info_file)
        return
    asset_info_list = json_operation.get_json_data(asset_info_file)
    if not asset_info_list:
        log.warning("No data in the json file %s." % asset_info_file)
        return
    cache_dir = get_anim_cache_dir(context)
    for asset_info in asset_info_list:
        asset_type = asset_info.get("type")
        asset_name = asset_info.get("name")
        namespace = asset_info.get("namespace")
        # project, entity_type, asset_type_sequence, asset_name_shot, step, task, version="", engine="maya"
        asset_shd_file = pipeFile.get_task_publish_file(
            context.project, "Asset", asset_type, asset_name, "Shd", "Shd")
        if os.path.isfile(asset_shd_file):
            create_reference.create_reference(asset_shd_file, namespace, True)
            log.info("Reference in %s" % asset_shd_file)
            cache_file = "%s/%s" % (cache_dir, "%s.abc" % namespace)
            if os.path.isfile(cache_file):
                log.info("attaching...")
                try:
                    import_exocortex_abc.import_exocortex_abc(cache_file)
                except:
                    log.error("Can't attach %s." % cache_file)
            else:
                log.warning("Cache: %s is not an exist file" % cache_file)
        else:
            log.warning("Shd: %s is not an exist file")
Beispiel #4
0
def main(file_name, local):
    logger = logging.getLogger("LgtLay start")
    new_file.new_file()
    context = pipeFile.PathDetails.parse_path(file_name)
    save_as.save_as(file_name)
    # create Light group
    import_lights(context)
    logger.info("Import light done.")
    # AR set
    rebuild_scene()
    logger.info("Rebuild scene done.")
    # switch to midmdl
    assemb = Assembly.Assembly()
    assemb.set_active("MidMdl")
    # get the AnimLay cache
    abc_files = get_cache_files(context)
    if abc_files:
        for abc_file in abc_files:
            if abc_file.endswith("env.abc"):
                continue
            namespace = os.path.splitext(os.path.basename(abc_file))[0]
            create_reference.create_reference(abc_file, namespace)
    logger.info("Reference cache done.")
    # fix frame range
    fix_frame_range.fix_frame_range(context)
    logger.info("Fix frame range done.")

    # set resolution
    resolution = Project(context.project).resolution
    set_image_size.set_image_size(*resolution)
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #5
0
def main(file_name, local):
    logger = logging.getLogger("Hair start")
    new_file.new_file()
    # copy low mdl publish file as mdl file
    context = pipeFile.PathDetails.parse_path(file_name)
    project = context.project
    entity_type = context.entity_type
    asset_type = context.asset_type
    asset_name = context.asset_name
    asset_type_short_name = context.asset_type_short_name
    yeti_name = "%s_%s_pgYetiMaya" % (asset_type_short_name, asset_name)
    create_yeti_node(asset_type_short_name, asset_name)
    mdl_publish_file = pipeFile.get_task_publish_file(project, entity_type,
                                                      asset_type, asset_name,
                                                      "HighMdl", "HighMdl")
    if not os.path.isfile(mdl_publish_file):
        logger.warning("No mdl file published.")
        quit_maya.quit_maya()
        return
    create_reference.create_reference(mdl_publish_file)
    create_hair_group(asset_type_short_name, asset_name)
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #6
0
def reference_in_camera(context):
    cache_dir = get_anim_cache_dir(context)
    camera_abc_file = "%s/%s" % (cache_dir, "camera.abc")
    if os.path.isfile(camera_abc_file):
        create_reference.create_reference(camera_abc_file)
    else:
        log.warning("%s is not an exist file" % camera_abc_file)
Beispiel #7
0
def main(file_name, local):
    logger = logging.getLogger("Lookdev start")
    new_file.new_file()
    context = pipeFile.PathDetails.parse_path(file_name)
    project = context.project
    entity_type = context.entity_type
    asset_type = context.asset_type
    asset_name = context.asset_name
    # reference in Shd
    shd_publish_file = pipeFile.get_task_publish_file(project, entity_type,
                                                      asset_type, asset_name,
                                                      "Shd", "Shd")
    if not os.path.isfile(shd_publish_file):
        logger.info("%s is not an exist file" % shd_publish_file)
        return
    create_reference.create_reference(shd_publish_file, asset_name)
    logger.info("reference shd done.")
    # import hair
    load_plugin.load_plugin("xgenToolkit.mll")
    mel.eval("XgCreateDescriptionEditor;")
    publish_file = pipeFile.get_task_file(project, asset_type, asset_name,
                                          "Hair", "Hair", "maya_asset_publish",
                                          "")
    context = pipeFile.PathDetails.parse_path(publish_file)
    import_xgen_hair(context, "hair")
    logger.info("import hair done.")
    # reference turn table
    reference_turntable()
    logger.info("reference turntable done.")
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #8
0
def main(file_name, local):
    logger = logging.getLogger("MidRig start")
    new_file.new_file()
    context = pipeFile.PathDetails.parse_path(file_name)
    project = context.project
    entity_type = context.entity_type
    asset_type = context.asset_type
    asset_type_short_name = context.asset_type_short_name
    asset_name = context.asset_name
    task = context.task
    MidMdl_publish_file = pipeFile.get_task_publish_file(
        project, entity_type, asset_type, asset_name, "MidMdl", "MidMdl")
    if not os.path.isfile(MidMdl_publish_file):
        logger.warning("No MidMdl file published.")
        quit_maya.quit_maya()
        return
    create_reference.create_reference(MidMdl_publish_file)
    model_name = "%s_%s_MODEL" % (asset_type_short_name, asset_name)
    # create root group
    root_group_name = "%s_%s_ROOT" % (asset_type_short_name, asset_name)
    create_group.create_group(root_group_name)
    # create _BLENDS group
    blends_group = "_BLENDS"
    create_group.create_group(blends_group)
    if asset_type == "Character":
        rig_group_name = "Grp_Master_Ctl"
        create_group.create_group("Others", root_group_name)
        create_group.create_group("Geometry", root_group_name)
        create_group.create_group(model_name, blends_group)
    elif asset_type in ["Prop", "Cprop", "Building"]:
        rig_group_name = "%s_%s_RIG" % (asset_type_short_name, asset_name)
        create_group.create_group(model_name, root_group_name)
        create_group.create_group(rig_group_name)
        if asset_type in ["Prop", "Building"]:
            bounding = mc.xform(model_name, q=1, bb=1)
            max_value = max(abs(bounding[0]), abs(bounding[2]),
                            abs(bounding[3]), abs(bounding[5]))
            radius = max_value * 1.1
            center = mc.xform(model_name, q=1, sp=1, ws=1)
            circle_list = mc.circle(c=center,
                                    nr=[0, 1, 0],
                                    r=radius,
                                    name="%s_%s_Ctl" %
                                    (asset_type_short_name, asset_name))
            circle_name = circle_list[0]
            constraint_parent = mc.parentConstraint(circle_name,
                                                    model_name,
                                                    maintainOffset=True)
            constraint_scale = mc.scaleConstraint(circle_name,
                                                  model_name,
                                                  maintainOffset=True)
            mc.parent(constraint_parent, rig_group_name)
            mc.parent(constraint_scale, rig_group_name)
            mc.parent(circle_name, rig_group_name)
    create_group.create_group(rig_group_name, root_group_name)
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #9
0
 def do_create_reference(self, index):
     index = self.asset_list_view.model().mapToSource(index)
     item = self.asset_model.model_data[index.row()]
     publish_path = item.publish_path
     namespace = item.name if self.name_space_cbox.currentText(
     ) == "asset name" else ":"
     if os.path.isfile(publish_path):
         create_reference.create_reference(publish_path, namespace, True)
Beispiel #10
0
def reference_cloth():
    context = pipeFile.PathDetails.parse_path()
    project = context.project
    template = Project(project).template("fx_cache_publish")
    cache_dir = template.format(project=project, sequence=context.sequence, shot=context.shot, step="Cfx")
    if not os.path.isdir(cache_dir):
        print "No cloth cache dir exist"
        return
    cloth_cache_path = glob.glob("%s/*/cloth/cloth.abc" % cache_dir)
    if cloth_cache_path:
        for cache in cloth_cache_path:
            create_reference.create_reference(cache, "cloth")
    else:
        print "No cloth cache found."
Beispiel #11
0
 def reference_in(self):
     paths = self.get_selected_path()
     if not paths:
         return
     if self.run_app.endswith("maya.exe"):
         progress_dialog = QProgressDialog('Reference in,Please wait......',
                                           'Cancel', 0, len(paths))
         progress_dialog.setWindowModality(Qt.WindowModal)
         progress_dialog.show()
         for index, path in enumerate(paths):
             create_reference.create_reference(path)
             progress_dialog.setValue(index + 1)
             if progress_dialog.wasCanceled():
                 break
Beispiel #12
0
def main(file_name, local):
    logger = logging.getLogger("HairRig start")
    context = pipeFile.PathDetails.parse_path(file_name)
    #  reference HighRig
    high_rig_file = pipeFile.get_task_publish_file(context.project, context.entity_type, context.asset_type,
                                                   context.asset_name, "HighRig", "HighRig")
    if not os.path.isfile(high_rig_file):
        logger.error("HighRig not publish file yet.")
        if not local:
            quit_maya.quit_maya()
        return
    create_reference.create_reference(high_rig_file)
    #  save file
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #13
0
 def replace_gpu_to_shd(self, gpu_node, path_type):
     if path_type == "mdl":
         path = gpu_node.mdl_path
     else:
         path = gpu_node.shd_path
     namespace = gpu_node.name
     group_name = create_reference.create_reference(path, namespace_name=namespace, allow_repeat=True, get_group=True)
     print group_name
     self.build_group(group_name, gpu_node.parent)
     self.set_attr(gpu_node, group_name)
Beispiel #14
0
def main(file_name, local):
    logger = logging.getLogger("shd start")
    new_file.new_file()
    context = pipeFile.PathDetails.parse_path(file_name)
    project = context.project
    entity_type = context.entity_type
    asset_type = context.asset_type
    asset_name = context.asset_name
    mdl_publish_file = pipeFile.get_task_publish_file(project, entity_type,
                                                      asset_type, asset_name,
                                                      "HighMdl", "HighMdl")
    if not os.path.isfile(mdl_publish_file):
        logger.warning("No model file published.")
        quit_maya.quit_maya()
        return
    create_reference.create_reference(mdl_publish_file)
    save_as.save_as(file_name)
    logger.info("%s publish successful!" % file_name)
    if not local:
        quit_maya.quit_maya()
Beispiel #15
0
def import_camera(project, sequence, step):
    db = db_api.DbApi(project).db_obj
    shots = db.get_all_shots(sequence)
    if not shots:
        print "No shot exist in this sequence"
        return
    shot_names = [shot.get("code") for shot in shots]
    for shot_name in shot_names:
        cache_template = Project(project).template("maya_shot_cache")
        cache_dir = cache_template.format(project=project, sequence=sequence,
                                          shot=shot_name.split("_")[-1], step=step, task=step)
        camera_cache_path = "%s/camera.abc" % cache_dir
        camera_cache_path = camera_cache_path.replace("\\", "/")
        if not os.path.isfile(camera_cache_path):
            print "%s is not exist." % camera_cache_path
            continue
        reference_files = mc.file(q=1, r=1, wcn=1)
        if camera_cache_path in reference_files:
            print "%s already exist" % camera_cache_path
            continue
        create_reference.create_reference(camera_cache_path)
    group_camera()
Beispiel #16
0
def create_reference_node(reference_node):
    model_group = get_model_group(reference_node)
    outliner_name = "%s:%s" % (reference_node.namespace, model_group)
    if mc.objExists(outliner_name):
        set_attr(reference_node)
        build_group(outliner_name, reference_node.parent)
    else:
        if not os.path.isfile(reference_node.mdl_path):
            logger.error("%s is not an exist path" % reference_node.mdl_path)
            return
        try:
            new_node = create_reference.create_reference(reference_node.mdl_path, reference_node.namespace, True, True)
            set_attr(reference_node, new_node)
            build_group(new_node, reference_node.parent)
            logger.info("Create reference: %s successful." % reference_node.mdl_path)
        except:
            logger.error("Create reference: %s failed." % reference_node.mdl_path)
Beispiel #17
0
def import_env_cache(abc_path):
    if os.path.isfile(abc_path):
        create_reference.create_reference(abc_path)
        logger.info("Import env cache done.")
    else:
        logger.warning("No env cache exists.")
Beispiel #18
0
def assign_shader(asset, shader_version):
    """
    assign shader by json configuration
    :param asset: pymel short asset name
    :param shader_version: default or other shader version
    :return:
    """
    not_exist_list = list()
    # get json path and data
    obj = pipeFile.PathDetails.parse_path()
    project = obj.project
    asset_short_name = asset.name()
    # below split(":") maybe some reference with namespace
    asset_type_simple = asset_short_name.split(":")[-1].split("_")[0]
    asset_type = ASSET_DICT[asset_type_simple]
    asset_name = asset_short_name.split(":")[-1].split("_")[1]
    json_dir = pipeFile.get_asset_step_dir(asset_type,
                                           asset_name,
                                           "shd",
                                           "_connection",
                                           project_name=project,
                                           shd_version=shader_version)
    json_path = join_path.join_path2(
        json_dir, "%s_%s_shd_v000.json" % (project, asset_name))
    if not json_path:
        logger.error("No connection json file found.")
        return
    json_data = json_operation.get_json_data(json_path)
    # get shd path and reference in
    shd_dir = pipeFile.get_asset_step_dir(asset_type,
                                          asset_name,
                                          "shd",
                                          "_sg",
                                          project_name=project,
                                          shd_version=shader_version)
    shd_path = join_path.join_path2(
        shd_dir, "%s_%s_shd_v000.mb" % (project, asset_name))
    if not shd_path:
        logger.error("No shading publish file found.")
        return
    # create reference
    create_reference.create_reference(shd_path)
    # assign shader
    asset_long_name = asset.longName()
    prefix = "|".join((asset_long_name.split("|")[:-1]))
    namespace_name = get_namespace.get_namespace(asset_short_name)
    namespace_name = namespace_name.strip(":")
    # has no parent group
    if not prefix:
        # -has no namespace
        if not namespace_name:
            not_exist = assign_shader_by_json_data(json_data)
            if not_exist:
                not_exist_list.extend(not_exist)
        # -has name space
        else:
            for mesh in json_data:
                mesh_list = mesh.split("|")
                final_mesh = ("|%s:" % namespace_name).join(mesh_list)
                if not mc.objExists(final_mesh):
                    exist_warning(final_mesh)
                    not_exist_list.append(final_mesh)
                    continue
                pm.sets(json_data[mesh]["sg"], fe=final_mesh)
                set_arnold_attribute(json_data, mesh, final_mesh)
    # has prefix (has parent group)
    else:
        # -has no namespace
        if not namespace_name:
            for mesh in json_data:
                final_mesh = prefix + mesh
                if not mc.objExists(final_mesh):
                    logger.warning("%s not exist." % final_mesh)
                    not_exist_list.append(final_mesh)
                    continue
                pm.sets(json_data[mesh]["sg"], fe=final_mesh)
                set_arnold_attribute(json_data, mesh, final_mesh)
        # -has namespace
        else:
            for mesh in json_data:
                mesh_list = mesh.split("|")
                final_mesh = ("|%s:" % namespace_name).join(mesh_list)
                final_mesh = prefix + final_mesh
                if not mc.objExists(final_mesh):
                    logger.warning("%s not exist." % final_mesh)
                    not_exist_list.append(final_mesh)
                    continue
                pm.sets(json_data[mesh]["sg"], fe=final_mesh)
                set_arnold_attribute(json_data, mesh, final_mesh)
    return not_exist_list