def new_viewport_preset(cache_file, preset_name=None, source_preset=None, panel=None): preset_data = database._parse_yaml(cache_file) if not preset_data: preset_data = {} existing_keys = preset_data.keys() if source_preset and source_preset in existing_keys: options = database.read_cache(source_preset, cache_file) if not preset_name: preset_name = 'Copy of ' + source_preset else: if not panel: panel = get_active_editor() options = capture.parse_view(panel) if not preset_name or preset_name in existing_keys: logger.info('key exists') preset_name = create_unique_name(existing_keys, new_key = preset_name, suffix = 'Preset') logger.info(preset_name) if not options: options = capture.parse_view(panel) else: preset_data[preset_name] = options logger.info("preset_name %s" + preset_name) preset_data[preset_name] = options database.dump_cache(preset_data, cache_file) return preset_name
def playblast_with_settings(viewport_preset=None, viewport_preset_yaml=None, **recArgs): ''' Playblast with the user-defined settings recArgs are the arguments needed for the capture command ''' # get default viewport preset config if viewport_preset and viewport_preset_yaml: cache_file = path.get_config_yaml(viewport_preset_yaml) viewportArgs = database.read_cache(viewport_preset, cache_file) else: viewportArgs = {} # process filenames filepath = recArgs["filename"] if not filepath: filepath = path.get_default_playblast_folder() filepath = path.sanitize(filepath) filepath_with_ext = add_extension(filepath, recArgs) if is_file_on_disk( filepath_with_ext) and not recArgs.get("force_overwrite"): filename = os.path.split(filepath_with_ext)[-1] message = '[{}] already exists.\nDo you want to replace it?'.format( filename) if not confirm_overwrite_dialogue(message) == 'yes': return recArgs["show_ornaments"] = False recArgs["viewer"] = False # merge with viewport args viewport_options = viewportArgs.copy() viewport_options.update(recArgs) logger.info("viewport_options: {}".format(viewport_options)) playblast_file = capture.capture(**viewport_options) if playblast_file: playblast_file = add_extension(playblast_file, recArgs) recArgs["filename"] = playblast_file database.save_last_recorded(recArgs) database.dump_cache({"last_recorded_selection": playblast_file}) logger.info('Find your recorded file here: {}'.format(playblast_file)) return playblast_file else: logger.info("playblast_with_settings failed")
def record(upload_after_creation=None, play_after_creation=None, show_success_msg=True): # This a wrapper function and if called individually should mirror all the same effect as hitting 'record' in the UI recordData = {} capturedFile = _record() if not capturedFile: return {"playblast_file": ""} logger.info("capturedFile: {}".format(capturedFile)) capturedFileNoExt, ext = os.path.splitext(capturedFile) if capturedFileNoExt[-5:] == '.####': #Reencode to quicktime recordData["playblast_file"] = video.encodeToH264Mov( capturedFile, output_file=capturedFileNoExt[:-5] + ".mov") logger.info("reencoded File: {}".format(recordData["playblast_file"])) database.dump_cache( {"last_recorded_selection": recordData["playblast_file"]}) else: recordData["playblast_file"] = capturedFile # Post actions # To Do - post Recording script call if upload_after_creation is None: upload_after_creation = True if database.read_cache( 'ps_upload_after_creation_checkBox') == 'true' else False if play_after_creation is None: play_after_creation = True if database.read_cache( 'ps_play_after_creation_checkBox') == 'true' else False open_after_creation = True if database.read_cache( 'ps_open_afterUpload_checkBox') == 'true' else False if upload_after_creation: uploaded_item = upload(open_after_upload=open_after_creation) recordData["uploaded_item"] = uploaded_item else: if play_after_creation: play(recordData["playblast_file"]) return recordData
def new_preset(self): """Create a new preset""" title = 'Creating Preset' message = 'Please choose a name for this preset.' user_input = InputDialog(self, title, message) if not user_input.response: return preset_name = user_input.response_text if not preset_name: logger.info("No new preset name specified") return preset_file = path.get_config_yaml(PRESET_YAML) current_preset_names = database._parse_yaml(preset_file).keys() if preset_name in current_preset_names: title = 'Error Creating' message = 'It appears this name already exists.' WarningDialog(self, title, message) return width, height = maya_scene.get_render_resolution() encoding = maya_scene.get_playblast_encoding() format = maya_scene.get_playblast_format() preset_data = { preset_name: { 'encoding': encoding, 'format': format, 'height': height, 'width': width } } logger.info("Create Format Preset from {}".format(preset_name)) database.dump_cache(preset_data, preset_file) self.populate_ui() self.ui.ui_formatPreset_comboBox.set_combobox_index( selection=preset_name)
def save(self): presetFile = path.get_config_yaml(PRESET_YAML) presetName = self.ui.ui_formatPreset_comboBox.currentText() format = self.ui.format_comboBox.currentText() encoding = self.ui.encoding_comboBox.currentText() width = self.ui.width_spinBox.value() height = self.ui.height_spinBox.value() newData = { presetName: { 'encoding': encoding, 'format': format, 'height': height, 'width': width } } database.dump_cache(newData, presetFile) self._update_current_preset(presetName) self.close()
def save_viewport_preset(cache_file, presetName, panel=None): if not panel: panel = get_active_editor() data = {} data[presetName] = capture.parse_view(panel) database.dump_cache(data, cache_file)