Maya 2022 playblast script problem

Maya 2022 playblast script problem

ciroskocho
Community Visitor Community Visitor
392 Views
1 Reply
Message 1 of 2

Maya 2022 playblast script problem

ciroskocho
Community Visitor
Community Visitor

So I have this little Python script that creates sequential playblast and save them in the same directory. I would like to make that the script after creates the playblast, open the video in Keyframe MP. I try some things but it doesnt work, it goes right again to the viewport and I need to go to de files explorer in Windows and find the video, and that is quite annoying when you're animating. So here Is the vanilla code. If someone can help me  I would appreciate a lot (the script is in spanish because is my first lenguage)

 

import maya.cmds as cmds
import os

def generate_playblast_sequence(*args):

 

# Obtener el nombre base para los playblasts
base_name = cmds.promptDialog(
title='Nombre de los playblasts',
message='Introduzca el nombre base:',
button=['Generar Playblast', 'Cancelar'],
defaultButton='Generar Playblast',
cancelButton='Cancelar',
dismissString='Cancelar'
)

 

# Verificar si el usuario ha introducido un nombre base
if base_name == 'Cancelar':
cmds.warning('Debe introducir un nombre base.')
return

 

# Obtener la resolución actual de la vista
width = cmds.getAttr('defaultResolution.width')
height = cmds.getAttr('defaultResolution.height')

# Definir las opciones de playblast
playblast_options = {
'format': 'qt',
'sequenceTime': False,
'clearCache': True,
'viewer': False,
'showOrnaments': True,
'fp': 4,
'percent': 100,
'compression': 'H.264',
'quality': 100,
'widthHeight': [width, height],
'sound': True
}

 

# Obtener el número de secuencia actual
sequence_number = 1

while True:

 

# Obtener la carpeta donde se guardarán los playblasts
folder_path = cmds.fileDialog2(fileMode=3, okCaption='Seleccionar carpeta')[0]

 

# Verificar si la carpeta existe
if not os.path.exists(folder_path):
cmds.warning('La carpeta especificada no existe.')
continue

 

# Actualizar el nombre de archivo en las opciones de playblast
playblast_options['filename'] = os.path.join(folder_path, base_name + '_' + str(sequence_number).zfill(4) + '.mov')

 

# Generar el playblast
cmds.playblast(**playblast_options)

 

# Mostrar un mensaje de confirmación
cmds.confirmDialog(title='Playblast generado', message='El playblast ha sido generado exitosamente.', button='OK')

 

# Incrementar el número de secuencia
sequence_number += 1

 

# Preguntar si se quiere generar otro playblast
confirm = cmds.confirmDialog(title='Generar otro playblast', message='¿Desea generar otro playblast?', button=['Si', 'No'], defaultButton='Si', cancelButton='No', dismissString='No')

if confirm == 'No':
break

 

# Agregar funcionalidad para generar el siguiente playblast con el mismo nombre base
def generate_next_playblast(*args):
nonlocal sequence_number

 

# Actualizar el nombre de archivo en las opciones de playblast
playblast_options['filename'] = os.path.join(folder_path, base_name + '_' + str(sequence_number).zfill(4) + '.mov')

 

# Generar el playblast
cmds.playblast(**playblast_options)

 

# Mostrar un mensaje de confirmación
cmds.confirmDialog(title='Playblast generado', message='El playblast ha sido generado exitosamente.', button='OK')

 

# Incrementar el número de secuencia
sequence_number += 1

cmds.button(label='Generar Siguiente Playblast', command=generate_next_playblast)

 

# Crear la ventana de interfaz de usuario
window_title = 'Generador de playblasts'
if cmds.window(window_title, exists=True):
cmds.deleteUI(window_title)
cmds.window(window_title, title=window_title, sizeable=False)
cmds.columnLayout(adjustableColumn=True)
cmds.button(label='Generar Playblast', command=generate_playblast_sequence)
cmds.showWindow()

0 Likes
393 Views
1 Reply
Reply (1)
Message 2 of 2

AdamBakerArt
Explorer
Explorer

There is a few thing you can do is create a subprocess that is run after this and we wont rely on maya at all or you can setup Maya's external application settings for view or image sequences 

 

For more information on subprocess LINK

 

But if you want to go the simpler root try going to:

 

  1. Preferences 
  2. Applications 
  3. Sequence Viewing Applications 
    1. Fill out the needed information linking to the exe or bin file for the application. 



 

 

0 Likes