Skip to content

Instantly share code, notes, and snippets.

@taikomatsu
Last active September 16, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taikomatsu/b8e354196a890f4036ed to your computer and use it in GitHub Desktop.
Save taikomatsu/b8e354196a890f4036ed to your computer and use it in GitHub Desktop.
Playblast Automater
# Mayaで大量のシーンのplayblastを一斉に取りたい時用のスクリプト。
# 事前に取得したシーンファイル名をムービー保存ディレクトリと一緒に渡すとプレイブラスト開始。
# このスクリプトではフォーカスしたいオブジェクトを記述すればそれにフォーカスしてプレイブラストをするものの、
# カメラの固定やジョイントの表示をOFFにしたいなどあれこれやりたいことはあると思うので、
# その場合はviewport settingsの下辺りに追加してやればOKのはず。
from pymel.core import *
import os
import os.path
def capture_anim(scene_file, movie_dir, focus_obj=None):
# open the scene
openFile(scene_file, f=True)
# setting for capturing
model_editor = 'MayaWindow|formLayout1|viewPanes|modelPanel4|modelPanel4|modelPanel4'
# viewport settings
# focus to specified object
if (focus_obj != None):
select(focus_obj, r=True)
setFocus(model_editor)
viewFit(f=1.0)
select(cl=True)
# set smooth shade with textures
modelEditor(model_editor, e=True, displayAppearance='smoothShaded', displayLights='default')
modelEditor(model_editor, e=True, displayTextures=True)
# exec playblast
scene_file_name = os.path.splitext(os.path.split(scene_file)[-1])[0]
movie_path = '{0}/{1}.mov'.format(movie_dir, scene_file_name)
if not os.path.isdir(movie_dir):
os.makedirs(movie_dir)
playblast(
format='qt',
filename=movie_path,
forceOverwrite=True,
sequenceTime=False,
viewer=False,
showOrnaments=False,
offScreen=True,
percent=100,
compression='H.264',
quality=80,
widthHeight=(1920, 1080))
print('[INFO] Done Playblast: {0}'.format(movie_path))
# usage
# capture_anim('Z:/path/to/the_maya_file.ma', 'Z:/path/to/the_movie_file.mov')
# capture_anim('Z:/path/to/the_maya_file.ma', 'Z:/path/to/the_movie_file.mov', 'obj_name')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment