def playblast_shot(submit=True): logger = logging.getLogger(__name__) valid_camera = get_valid_camera.get_valid_camera() if not valid_camera: raise Exception("No valid camera found.") frame_range = get_frame_range.get_frame_range() context = pipeFile.PathDetails.parse_path() current_project = context.project resolution = Project(current_project).resolution percent = Project(current_project).playblast_percent set_image_size.set_image_size(*resolution) local_video_path = context.local_video_path video_path = context.work_video_path create_parent_dir.create_parent_dir(local_video_path) playblaster.playblaster(local_video_path, valid_camera, frame_range[0], frame_range[1], resolution, percent, open_it=True) logger.info("Playblast to %s" % local_video_path) # backup video path if submit: Copy.copy(local_video_path, video_path) logger.info("Copy %s >> %s" % (local_video_path, video_path)) return video_path else: return local_video_path
def playblast_turntable(submit=True): logger = logging.getLogger(__name__) # get path obj = pipeFile.PathDetails.parse_path() local_video_path = obj.local_video_path work_video_path = obj.work_video_path current_project = obj.project # playblast model_name = get_model_name.get_model_name() resolution = Project(current_project).resolution percent = Project(current_project).playblast_percent set_image_size.set_image_size(*resolution) mc.select(model_name, r=1) create_turntable.create_turntable() create_parent_dir.create_parent_dir(local_video_path) playblaster.playblaster(local_video_path, "tt_camera", 1, 120, resolution, percent, False, None, True) remove_turntable.remove_turntable() logger.info("playblast done.") mc.lookThru("persp") if submit: Copy.copy(local_video_path, work_video_path) logger.info("Copy %s >> %s" % (local_video_path, work_video_path)) return work_video_path else: return local_video_path
def __init__(self): self.logger = logging.getLogger("Playblast Lay") self.obj = pipeFile.PathDetails.parse_path() self.current_project = self.obj.project self.resolution = Project(self.current_project).resolution set_image_size.set_image_size(*self.resolution) self.percent = Project(self.current_project).playblast_percent self.local_dir = Project(self.current_project).local_root_dir
def get_cache_dir(): context = pipeFile.PathDetails.parse_path() project = context.project template = Project(project).template("fx_cache_work") cache_dir = template.format(project=project, sequence=context.sequence, shot=context.shot, step="Cfx") return cache_dir
def run(self): default_image_path = join_path.join_path2(self.__image_dir, "unknown.png") if self.__show_image: project_data = Project(self.__project) primary = project_data.primary if self.__entity_type == "Asset": format_str = project_data.template("maya_asset_image") step = "MidMdl" task = "MidMdl" else: format_str = project_data.template("maya_shot_image") step = "AnimLay" task = "AnimLay" engine = Step(self.__project, step).engine for entity in self.__entities: entity_name = entity.get("code") image_path = format_str.format( primary=primary, project=self.__project, asset_type=self.__asset_type_sequence, sequence=self.__asset_type_sequence, asset_name=entity_name, shot=entity_name.split("_")[-1], step=step, task=task, engine=engine) if self.__entity_type == "Asset" and not os.path.isfile( image_path): image_path = format_str.format( primary=primary, project=self.__project, asset_type=self.__asset_type_sequence, asset_name=entity_name, step="Group", task="Group", engine=engine) if self.__entity_type == "Shot" and not os.path.isfile( image_path): image_path = format_str.format( primary=primary, project=self.__project, sequence=self.__asset_type_sequence, shot=entity_name.split("_")[-1], step="Set", task="Set", engine=engine) if not os.path.isfile(image_path): image_path = default_image_path self.__collect_data.append([entity_name, image_path]) else: for entity in self.__entities: entity_name = entity.get("code") self.__collect_data.append([entity_name, default_image_path]) self.signal.emit(self.__collect_data)
def init(self): asset_step_list = Project(self.project).asset_steps if "art" in asset_step_list: asset_step_list.remove("art") src_cbox_model = ComboModel(asset_step_list, self.src_cbox) dst_cbox_model = ComboModel(asset_step_list, self.dst_cbox) self.src_cbox.setModel(src_cbox_model) self.dst_cbox.setModel(dst_cbox_model) self.src_cbox.setCurrentIndex(self.src_cbox.count() + 1) self.dst_cbox.setCurrentIndex(self.src_cbox.count() + 1) self.tree_view.setSortingEnabled(True) self.tree_view.setFocusPolicy(Qt.NoFocus) self.tree_view.setSelectionMode(QAbstractItemView.ExtendedSelection)
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."
def get_logger(project, logger_type, task_name): logger_dir = Project(project).task_log_dir logger_dir = logger_dir.format(project=project) logger_dir = join_path.join_path2(logger_dir, logger_type) if not os.path.isdir(logger_dir): os.makedirs(logger_dir) current_time = time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime()) file_base_name = "%s-%s.txt" % (task_name, current_time) file_name = join_path.join_path2(logger_dir, file_base_name) logging.basicConfig(filename=file_name, level=logging.DEBUG, filemode='w', format='%(asctime)s - %(levelname)s: %(message)s') logger = logging.getLogger() return logger
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()
def reference_turntable(): current_project = get_current_project.get_current_project() current_root = Project(current_project).primary turn_table_template_path = "%s/%s/templates/turnTable/turn_table.mb" % ( current_root, current_project) if os.path.isfile(turn_table_template_path): mc.file(turn_table_template_path, r=1, namespace='turntable') else: mc.confirmDialog(title='Error', message='turn table not exists')
def init_db_menu(*args): from miraLibs.pipeLibs import Project path = get_scene_name.get_scene_name() obj = pipeFile.PathDetails.parse_path(path) if not obj: return project = obj.project database = Project(project).database if database == "shotgun": init_shotgun_menu(project)
def maya_publish(self): # publish mayabatch cmd to deadline publish_py = self.get_publish_py() if not os.path.isfile(publish_py): self.logger.error("%s is not an exist file" % publish_py) return mayabatch = Project(self.context.project).mayabatch_path cmd = '\"\"%s\" -command \"python \"\"file_name=\'%s\';execfile(\'%s\')\"\"\"\"' % ( mayabatch, self.work_file, publish_py) self.run_command(cmd) self.post_publish()
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()
def maya_start(self): start_py = self.get_start_py() if not os.path.isfile(start_py): self.logger.error("%s is not an exist file" % start_py) return mayabatch = Project(self.project).mayabatch_path cmd = '\"\"%s\" -command \"python \"\"file_name=\'%s\';execfile(\'%s\')\"\"\"\"' % ( mayabatch, self.work_file, start_py) self.logger.info("cmd:\n\n%s\n\n" % cmd) return_file = os.popen(cmd) self.logger.info(return_file.read()) return_file.close() self.post_start()
def show_context_menu(self, pos): # add entity menu and action self.__main_menu.clear() actions = self.get_actions().get(self.entity_type) if not actions: return entity_actions = actions.get("entity").get("actions") task_actions = actions.get("task").get("actions") selected = self.__get_selected() if not selected: return asset_shot_names = [item.name for item in selected] out_arg = [ self.project, self.entity_type, self.asset_type_sequence, asset_shot_names ] for action in entity_actions: entity_action = self.__entity_action_group.addAction(action) entity_action.attr = out_arg self.__main_menu.addAction(entity_action) if not task_actions: return # add task menu and action if len(selected) > 1: if self.entity_type == "Asset": steps = Project(self.project).asset_steps else: steps = Project(self.project).shot_steps if len(selected) == 1: steps = self.db.get_step(self.entity_type, self.asset_type_sequence, asset_shot_names[0]) if not steps: return steps = list(set(steps)) steps.sort() for step in steps: step_menu = self.__main_menu.addMenu(step) step_menu.up_level = self.__main_menu if len(selected) == 1: tasks = self.db.get_task(self.entity_type, self.asset_type_sequence, asset_shot_names[0], step) tasks = [task.get("code") for task in tasks] else: tasks = [step] if not tasks: continue for task in tasks: task_menu = step_menu.addMenu(task) task_menu.up_level = step_menu for action in task_actions: task_action = self.__task_action_group.addAction(action) task_action.up_level = task_menu task_action.attr = out_arg task_menu.addAction(task_action) global_pos = self.list_view.mapToGlobal(pos) self.__main_menu.exec_(global_pos)
def get_tk(self): """ get the toolkit instance :return: database instance """ database = Project(self.project).data_base if database == "shotgun": from miraLibs.sgLibs import Tk tk = Tk.Tk(self.project) elif database == "strack": tk = None # todo add strack api methods else: tk = None return tk
def nuke_publish(self): custom_dir = pipeGlobal.custom_dir publish_dir = join_path.join_path2(custom_dir, self.project, "publish") if not os.path.isdir(publish_dir): publish_dir = join_path.join_path2(custom_dir, "defaultProject", "publish") publish_py = join_path.join_path2(publish_dir, "%s.py" % self.context.step) if not os.path.isfile(publish_py): self.logger.error("%s is not an exist file" % publish_py) return nuke_path = Project(self.context.project).nuke_path cmd = "%s -t %s %s" % (nuke_path, publish_py, self.work_file) self.run_command(cmd) self.post_publish()
def __init__(self, parent=None): super(QC, self).__init__(parent) self.setWindowTitle("QC Publish") self.resize(430, 600) self.context = pipeFile.PathDetails.parse_path() self.project = self.context.project self.entity_type = self.context.entity_type self.work_image_path = self.context.work_image_path self.local_image_path = self.context.local_image_path self.step = self.context.step self.other_dir = self.context.other_dir self.video_path = self.context.work_video_path self.next_version_file = self.context.next_version_file self.playblast_step = Project(self.project).playblast_step self.has_playblast = self.step in self.playblast_step self.setup_ui()
def get_db(self): """ get the database instance :return: database instance """ if self.project: database = Project(self.project).database else: database = "strack" if database == "shotgun": from miraLibs.sgLibs import Sg db = Sg.Sg(self.project) elif database == "strack": from miraLibs.stLibs import St db = St.St(self.project) else: from miraLibs.stLibs import St db = St.St(self.project) return db
def main(file_name, local): logger = logging.getLogger("Lgt start") load_plugin.load_plugin("AbcImport.mll") load_plugin.load_plugin("MayaExocortexAlembic.mll") 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.") # rebuild scene rebuild_scene() logger.info("Rebuild scene done.") # edit shd edit_shd(context) logger.info("Edit shd done.") # rebuild asset rebuild_asset(context) logger.info("Rebuild asset done.") # transfer attribute transfer_attribute.transfer_attribute() logger.info("Transfer attribute done.") # break visibility connections break_visibility_connections.break_visibility_connections() # reference camera reference_in_camera(context) # group assets group_assets() group_camera(file_name) # # assembly switch to shd # assembly = Assembly.Assembly() # assembly.set_active("Shd") # 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("Publish done.") if not local: quit_maya.quit_maya()
def on_export(self): cache_dir = pipeFile.get_task_file(self.project, self.sequence, self.shot, self.step, self.task, "maya_shot_cache") camera_cache_path = "%s/camera.abc" % cache_dir if not os.path.isfile(camera_cache_path): QMessageBox.critical(None, "Warming Tip", u"没有摄像机的.abc缓存文件") return frame_range = self.db.get_shot_task_frame_range( "%s_%s" % (self.sequence, self.shot)) if not frame_range: QMessageBox.critical(None, "Warming Tip", u"strack上没有设置该镜头的帧范围") return start, end = [int(i) for i in frame_range.split("-")] py_path = os.path.abspath( os.path.join(__file__, "..", "export_in_maya.py")) py_path = py_path.replace("\\", "/") mayabatch = Project(self.project).mayabatch_path cmd = "\"%s\" -command \"python \\\"file_name='%s';start=%s;end=%s;execfile('%s')\\\"\"" % ( mayabatch, camera_cache_path, start, end, py_path) print cmd subprocess.Popen(cmd, shell=True) QMessageBox.information(None, "Warming Tip", u"开始导出,稍后会将路径弹出。")
def show_pictures(self, value): if not value: print "has no value" self.set_empty_model() else: project, sequence, shot, step = value work_template = Project(project).template("maya_shot_render") work_dir = work_template.format(project=project, sequence=sequence, shot=shot.split("_")[-1], step=step) publish_template = Project(project).template( "maya_shot_renderPublish") publish_dir = publish_template.format(project=project, sequence=sequence, shot=shot.split("_")[-1], step=step) self.set_dir(work_dir, "work", "version") self.set_dir(publish_dir, "publish", "texture")
def init_step(self): shot_steps = Project(self.project).shot_steps self.step_combo.addItems(shot_steps) self.step_combo.setCurrentIndex(self.step_combo.count() + 1)
def init(self): asset_types = Project(self.project).asset_type self.asset_type_combo.addItems(asset_types) self.set_asset_name()
def pipeline_steps(self): if self.entity_type == "Asset": return Project(self.project).asset_steps else: return Project(self.project).shot_steps
def __init_asset_type(self): asset_types = Project(self.project).asset_type for asset_type in asset_types: self.asset_type_check = QCheckBox(asset_type) self.asset_btn_grp.addButton(self.asset_type_check) self.asset_layout.addWidget(self.asset_type_check)
def get_dir(self, step, work_type, submit_type=None): if step in ["LgtLay", "Lgt"]: if work_type == "work": template = Project(self.project).template("maya_shot_render") else: template = Project( self.project).template("maya_shot_renderPublish") else: if work_type == "work": if submit_type == "Cache": template = Project(self.project).template("fx_cache_work") else: template = Project(self.project).template("fx_render_work") else: if submit_type == "Cache": template = Project( self.project).template("fx_cache_publish") else: template = Project( self.project).template("fx_render_publish") return template.format(project=self.project, sequence=self.sequence, shot=self.shot, step=self.step)
def __init__(self): self.current_project = get_current_project.get_current_project() self.current_root = Project(self.current_project).primary