Пример #1
0
def export_other_cache(context, category):
    """
    export cprop prop and character cache
    :param context:
    :param category: Prop or Character
    :return:
    """
    if not mc.objExists(category):
        return
    cache_dir = context.cache_dir
    start, end = get_frame_range.get_frame_range()
    if context.step == "AnimLay":
        if category == "Prop":
            models = get_models.get_models("Prop")
        else:
            children = mc.listRelatives("Char", ad=1, type="transform")
            models = [i for i in children if i.endswith("DeformationSystem") or i.endswith("_MODEL")]
        if models:
            for model in models:
                namespace = get_namespace.get_namespace(model)
                cache_path = "%s/%s.abc" % (cache_dir, namespace)
                do_export(start, end, cache_path, model)
    elif context.step == "Anim":
        from miraLibs.pipeLibs.pipeMaya.anim import export_model_abc
        export_model_abc.export_model_abc()
Пример #2
0
def get_has_cloth_asset():
    if not mc.objExists("Char"):
        return
    characters = mc.listRelatives("Char", type="transform")
    if not characters:
        return
    characters = [get_namespace.get_namespace(char) for char in characters]
    return characters
Пример #3
0
 def get_node_info(self):
     self.attr = self.get_attr_dict()
     if self.name.endswith("_MODEL") or self.name.endswith("_ROOT"):
         self.node_type = "reference_model"
         self.namespace = str(get_namespace.get_namespace(self.name))
         self.mdl_path = self.get_mdl_path()
     else:
         self.node_type = "transform"
     self.parent = self.get_parent()
Пример #4
0
 def get_error_list(self):
     top_groups = self.get_top_groups()
     if not top_groups:
         return
     error_list = list()
     for grp in top_groups:
         suffix = grp.split(":")[-1]
         asset_name = suffix.split("_")[1]
         namespace = get_namespace.get_namespace(grp)
         if not namespace.startswith(asset_name):
             error_list.append(grp)
     return error_list
Пример #5
0
def export_hair_cache(description):
    sel = mc.ls(sl=1)
    if not sel:
        QMessageBox.warning(None, "Warming Tip", "Select something first.")
        return
    root_cache_dir = get_cache_dir()
    version = get_version()
    max_frame = get_max_frame()
    namespace = get_namespace.get_namespace(description)
    file_name = description.split(":")[-1]
    cache_file = "%s/%s/%s/hair/%s.abc" % (root_cache_dir, version, namespace,
                                           file_name)
    cache_dir = os.path.dirname(cache_file)
    if not os.path.isdir(cache_dir):
        os.makedirs(cache_dir)
    export_abc.export_abc(990, max_frame, cache_file, sel, uv_write=False)
Пример #6
0
def get_asset_type_list(group):
    asset_info_list = list()
    assets = get_assets_under_type_group.get_assets_under_type_group(group)
    if assets:
        for asset in assets:
            temp_dict = dict()
            model_name = asset.split(":")[-1]
            name = model_name.split("_")[1]
            asset_type_short_name = model_name.split("_")[0]
            asset_type = ASSET_DICT.get(asset_type_short_name)
            namespace = get_namespace.get_namespace(asset)
            temp_dict["name"] = str(name)
            temp_dict["namespace"] = str(namespace)
            temp_dict["type"] = str(asset_type)
            asset_info_list.append(temp_dict)
    return asset_info_list
Пример #7
0
def export_sculp():
    sculps = [t for t in mc.ls(type="transform") if t.endswith("_SCULP")]
    if not sculps:
        return
    max_frame = get_max_frame()
    root_cache_dir = get_cache_dir()
    version = get_version()
    for sculp in sculps:
        namespace = get_namespace.get_namespace(sculp)
        cache_dir = "%s/%s/%s/sculp" % (root_cache_dir, version, namespace)
        children = mc.listRelatives(sculp, c=1, type="transform")
        for t in children:
            no_namespace_name = t.split(":")[-1]
            shapes = mc.listRelatives(t, type="shape", ni=1)
            needed_shapes = list(set(shapes) - set(mc.ls(shapes, io=1)))
            if len(needed_shapes) != 1:
                logging.error("More than one shape under %s" % t)
                continue
            export_geometry_cache(cache_dir, no_namespace_name, 990, max_frame,
                                  needed_shapes[0])
            logging.info("Export %s cache to %s" %
                         (needed_shapes[0], cache_dir))
Пример #8
0
def export_single_abc(asset):
    context = pipeFile.PathDetails.parse_path()
    mc.parent(asset, world=1)
    namespace = get_namespace.get_namespace(asset)
    abc_name = "%s.abc" % namespace
    abc_path = os.path.join(context.cache_dir, abc_name).replace("\\", "/")
    start, end = get_frame_range.get_frame_range()
    meshes = mc.listRelatives(asset, ad=1, type="mesh")
    geo = [mc.listRelatives(mesh, p=1)[0] for mesh in meshes]
    objects = list(set(geo))
    if os.path.isfile(abc_path):
        export_exocortex_abc.export_exocortex_abc(abc_path, 950, end, objects)
    else:
        cache_dir, base_name = os.path.split(abc_path)
        with Temporary(dir_="D:/") as temp_dir:
            temp_path = "%s/tmp/%s" % (temp_dir, base_name)
            link_path = "%s/%s" % (temp_dir, base_name)
            export_exocortex_abc.export_exocortex_abc(temp_path, 950, end,
                                                      objects)
            if os.path.isfile(temp_path) and not os.path.isfile(link_path):
                os.system('mklink /H "%s" "%s"' % (link_path, temp_path))
                copy.copy(link_path, abc_path)
            else:
                print "mklink faild."
Пример #9
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