def replace_mdl_reference_shd():
    """
    replace mdl reference to shd.
    """
    logger = logging.getLogger(__name__)
    transforms = mc.listRelatives("env", ad=1, c=1, type="transform")
    ref_files = list()
    for transform in transforms:
        if mc.referenceQuery(transform,
                             inr=1) and transform.endswith("_MODEL"):
            ref_file = mc.referenceQuery(transform, filename=1)
            ref_files.append(ref_file)
    logger.info("reference files: %s" % ref_files)
    if not ref_files:
        return
    for ref_file in ref_files:
        obj = pipeFile.PathDetails().parse_path(ref_file)
        if not obj:
            continue
        project = obj.project
        asset_type = obj.asset_type
        asset_name = obj.asset_name
        ref_node = mc.referenceQuery(ref_file, rfn=1)
        logger.info("reference node: %s" % ref_node)
        shd_publish_path = pipeFile.get_asset_step_publish_file(
            asset_type, asset_name, "shd", project)
        if shd_publish_path:
            replace_reference.replace_reference(ref_node, shd_publish_path)
        else:
            logger.error("%s's shd publish file is not exist." % asset_name)
Exemple #2
0
 def do_switch(self):
     selected_assets = self.get_selected_assets()
     if not selected_assets:
         return
     for asset in selected_assets:
         model_name = asset[0]
         asset_type_short_name = model_name.split(":")[-1].split("_")[0]
         asset_type = ASSET_DICT[asset_type_short_name]
         asset_name = model_name.split(":")[-1].split("_")[1]
         shd_version = asset[1]
         shd_file = pipeFile.get_asset_step_publish_file(
             asset_type, asset_name, "shd", self.current_project,
             shd_version)
         if shd_file:
             if os.path.isfile(shd_file):
                 ref_node = mc.referenceQuery(model_name, rfn=1)
                 ref_file = mc.referenceQuery(model_name, f=1)
                 if shd_file != ref_file:
                     replace_reference.replace_reference(ref_node, shd_file)
                     lgt_assign_shader_deformed.lgt_assign_shader_deformed(
                         ref_node)
             else:
                 self.logger.error("%s %s %s shader file not exist." %
                                   (asset_type, asset_name, shd_version))
     self.message_box("Switch shader done.")
Exemple #3
0
 def do_replace(self):
     selected = self.get_selected()
     if not selected:
         return
     for asset_item in selected:
         group_name = asset_item.name
         ref_file = self.maya.get_reference_file(group_name)
         rig_path = self.get_rig_publish_path(ref_file)
         if not rig_path:
             logger = Logger(__name__)
             logger.warning("%s is not an exist file" % rig_path)
             continue
         ref_node = self.maya.get_reference_node(group_name)
         replace_reference.replace_reference(ref_node, rig_path)
     self.do_update()
Exemple #4
0
def replace(group_name, new_path):
    ref_node = mc.referenceQuery(group_name, referenceNode=1)
    replace_reference.replace_reference(ref_node, new_path)