Last active
January 18, 2016 13:36
-
-
Save internetimagery/e7bc290bd9d1b5b1f089 to your computer and use it in GitHub Desktop.
playblast to djviewer, http://djv.sourceforge.net/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import maya.utils as utils | |
| import maya.cmds as cmds | |
| import subprocess | |
| import threading | |
| import tempfile | |
| import platform | |
| import os.path | |
| import shutil | |
| import re | |
| import os | |
| def get_windows_command(): | |
| root = r"C:\Program Files" | |
| for folder in os.listdir(root): | |
| if re.match(r"djv-[\d\.]+-Windows.", folder): | |
| return os.path.join(root, folder, "bin", "djv_view.com") | |
| def render(path): | |
| sequence = os.path.join(path, "sequence") | |
| cmds.playblast( | |
| viewer=False, | |
| showOrnaments=False, | |
| format="image", | |
| filename=sequence.replace("\\", "/") | |
| ) | |
| def preview(folder, command): | |
| try: | |
| for f in os.listdir(folder): | |
| start = os.path.join(folder, f) | |
| subprocess.call((command, start)) # Block | |
| break | |
| finally: | |
| shutil.rmtree(folder) | |
| system = platform.system() | |
| if system == "Windows": | |
| command = get_windows_command() | |
| else: | |
| raise Exception("OS not supported") | |
| if command and os.path.isfile(command): | |
| tmp_folder = tempfile.mkdtemp() | |
| try: | |
| render(tmp_folder) | |
| finally: | |
| th = threading.Thread(target=preview, args=(tmp_folder, command)).start() | |
| else: | |
| import webbrowser | |
| print "Cannot find DJVIewer. Please download and install it." | |
| webbrowser.open("http://djv.sourceforge.net/index.html") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment