def update_cache(self, force=False): """ Updates internal cache with the current shots located in Artella server """ if self._cache and not force: return self._cache python.clear_list(self._cache) return artellapipe.ShotsMgr().find_all_shots(force_update=force)
def get_thumbnail_path(self): """ Implements abstract get_path function Returns the path where shot thumbnail is located :return: str """ thumb_attr = artellapipe.ShotsMgr().config.get('data', 'thumb_attribute') thumb_path = self._shot_data.get(thumb_attr, None) return thumb_path
def get_tasks_for_shot(self, shot_name): """ Returns all tasks attached to the given shot :param shot_name: str :return: """ shot_found = artellapipe.ShotsMgr().find_shot(shot_name) if not shot_found: LOGGER.warning('No shot found with name: "{}"!'.format(shot_name)) return None return artellapipe.Tracker().get_tasks_in_shot(shot_found.get_id())
def get_min_time(self): """ Returns minimum frame in timeline of shot taking into account all non muted shots :return: int """ non_muted_shots = artellapipe.ShotsMgr().find_non_muted_shots() if not non_muted_shots: return 0.0 least_time = min([shot.get_start_frame() for shot in non_muted_shots]) return least_time
def get_max_time(self): """ Returns maximum frame in timeline of shot taking into account all non muted shots :return: int """ non_muted_shots = artellapipe.ShotsMgr().find_non_muted_shots() if not non_muted_shots: return 0.0 greatest_time = max([shot.get_end_frame() for shot in non_muted_shots]) return greatest_time
def get_min_sequencer(self): """ Returns minimum frame in sequencer of shot taking into account all non muted shots :return: int """ non_muted_shots = artellapipe.ShotsMgr().find_non_muted_shots() if not non_muted_shots: return 0.0 greatest_time = min( [shot.get_sequencer_start_frame() for shot in non_muted_shots]) return greatest_time
def get_sequence(self): """ Returns the name of the sequence this shot belongs to :return: str """ sequence_attr = artellapipe.ShotsMgr().config.get( 'data', 'sequence_attribute') sequence_name = self._shot_data.get(sequence_attr, None) if not sequence_name: LOGGER.warning( 'Impossible to retrieve sequence name because shot data does not contains "{}" attribute.' '\nSequence Data: {}'.format(sequence_attr, self._shot_data)) return None return sequence_name
def get_name(self): """ Implements abstract get_name function Returns the name of the sequence :return: str """ name_attr = artellapipe.ShotsMgr().config.get('data', 'name_attribute') shot_name = self._shot_data.get(name_attr, None) if not shot_name: LOGGER.warning( 'Impossible to retrieve shot name because shot data does not contains "{}" attribute.' '\nSequence Data: {}'.format(name_attr, self._shot_data)) return None return shot_name.rstrip()
def get_id(self): """ Implements abstract get_id function Returns the id of the shot :return: str """ id_attr = artellapipe.ShotsMgr().config.get('data', 'id_attribute') asset_id = self._shot_data.get(id_attr, None) if not asset_id: LOGGER.warning( 'Impossible to retrieve asset ID because asset data does not contains "{}" attribute.' '\nAsset Data: {}'.format(id_attr, self._shot_data)) return None return asset_id.rstrip()
def get_number(self): """ Returns the number of the shot :return: str """ name_attr = artellapipe.ShotsMgr().config.get('data', 'number_attribute') shot_number = self._shot_data.get(name_attr, None) if not shot_number: LOGGER.warning( 'Impossible to retrieve shot number because shot data does not contains "{}" attribute.' '\nSequence Data: {}'.format(name_attr, self._shot_data)) return None return shot_number.rstrip()
def get_file_type(self, file_type, extension=None): """ Returns sequence file object of the current sequence and given file type :param file_type: str :param extension: str :return: ArtellaAssetType """ if file_type not in self.FILES: return None sequence_file_class = artellapipe.ShotsMgr().get_shot_file(file_type=file_type, extension=extension) if not sequence_file_class: LOGGER.warning( 'File Type: {} | {} not registered in current project!'.format(file_type, extension)) return return sequence_file_class(shot=self)
def process(self, context): import maya.cmds as cmds project = None for name, value in artellapipe.__dict__.items(): if name == 'project': project = value break assert project, 'Project not found' shots = cmds.ls(type='shot') for shot in shots: shot_node = artellapipe.ShotsMgr().find_shot(shot) if not shot_node: continue instance = context.create_instance(shot, project=project) instance.data['shot'] = shot_node instance.data['family'] = 'shots'
def process(self, instance): if not instance.data.get('publish', False): return False project = instance.data.get('project', None) assert project, 'No valid project defined in current instance: {}'.format( instance) shots_config = tp.ConfigsMgr().get_config( config_name='artellapipe-shots') assert shots_config, 'No valid shots configuration file found in current instance: {}'.format( instance) shot_node = instance.data.get('shot', None) assert shot_node, 'No valid shot node found in current instance: {}'.format( instance) # Retrieve master layout file path sequence_name = shot_node.get_sequence() assert sequence_name, 'No valid sequence name found linked to current instance: {}'.format( instance) sequence = artellapipe.SequencesMgr().find_sequence(sequence_name) assert sequence, 'No valid sequence found linked to current instance: {}'.format( instance) sequence_file_type = sequence.get_file_type('master') assert sequence, 'File type "master" not found in current project' sequence_file_type.open_file() shot_name = shot_node.get_name() assert tp.Dcc.object_exists( shot_name), 'No valid shot found in current instance: {}'.format( instance) all_shots = artellapipe.ShotsMgr().find_all_shots() assert all_shots, 'No shots defined in current project!' start_frame = shots_config.get('start_frame', default=101) found = False for shot in all_shots: if shot.get_name() == shot_name: found = True break assert found, 'Shot with name: "{}" not found in current sequence!'.format( shot_name) new_version = bool( util.strtobool( os.environ.get( '{}_SEQUENCES_PUBLISHER_NEW_VERSION'.format( project.get_clean_name().upper()), 'False'))) base_comment = '{} | {} | Sequences Publisher > Shot "{}" Export'.format( timedate.get_current_time(), osplatform.get_user(True), shot_name) comment = instance.data.get('comment', None) if comment: base_comment = '{} | {}'.format(base_comment, comment) valid_export = artellapipe.ShotsMgr().export_shot( shot_name, start_frame=start_frame, new_version=new_version, comment=base_comment) assert valid_export, 'Shot with name "{}" was not exported successfully!'.format( shot_name) return True
def get_data(self, sequence_range, start_duplicate_index=None, force_update=False): """ Returns data of current node :param sequence_range: list(int, int), start and enf frame of shot in sequencer timeline when shot range is different than shot's sequence range. When the shot has one or more shots overlapping, it causes section of the shot to be played multiple times :param start_duplicate_index: int, pass if we want to duplicate camera :param force_update: bool :return: dict """ if self._data and not force_update: return self._data sequence_start_frame = sequence_range[0] sequence_end_frame = sequence_range[-1] shot_sequencer_start_frame = self.get_sequencer_start_frame() shot_sequencer_end_frame = self.get_sequencer_end_frame() shot_pre_hold = self.get_pre_hold() shot_post_hold = self.get_post_hold() shot_scale = self.get_scale() shot_start_frame = self.get_start_frame() shot_end_frame = self.get_end_frame() pre_hold = 0.0 pre_hold_in = None if sequence_start_frame < shot_sequencer_start_frame + shot_pre_hold: pre_hold = shot_sequencer_start_frame + shot_pre_hold - sequence_start_frame elif sequence_start_frame > shot_sequencer_start_frame + shot_pre_hold: pre_hold_in = sequence_start_frame - (shot_sequencer_start_frame + shot_pre_hold) post_hold = 0.0 post_hold_in = None if sequence_end_frame > shot_sequencer_end_frame - shot_post_hold: post_hold = sequence_end_frame - (shot_sequencer_end_frame - shot_post_hold) elif sequence_end_frame < shot_sequencer_end_frame - shot_post_hold: post_hold_in = shot_sequencer_end_frame - shot_post_hold - sequence_end_frame time_start_frame = shot_start_frame if pre_hold_in is not None: time_start_frame = pre_hold_in / shot_scale + shot_start_frame time_end_frame = shot_end_frame if post_hold_in is not None: time_end_frame = (sequence_end_frame - shot_sequencer_start_frame ) / shot_scale + shot_start_frame shot_node_name = self.get_name() if start_duplicate_index is not None: shot_node_name = artellapipe.ShotsMgr().get_shot_unique_name( self.get_name(), start=start_duplicate_index) shot_camera = self.get_camera() shot_track = self.get_track_number() shot_dict = { 'shot_name': shot_node_name, 'track': shot_track, 'camera': shot_camera, 'sequence_start_frame': sequence_start_frame, 'sequence_end_frame': sequence_end_frame, 'prehold': pre_hold, 'posthold': post_hold, 'shot_scale': shot_scale, 'time_start_frame': time_start_frame, 'time_end_frame': time_end_frame } return shot_dict