def setFrames(self, path): # The easy part. super(Widget, self).setFrames(path) # Open a viewer, and wait for it to close. sound_path = get_sound_for_frames(path) or get_current_sound() frame_rate = cmds.playbackOptions(q=True, framesPerSecond=True) houdini_style_path = re.sub(r'(#+)', lambda m: '$F%d' % len(m.group(1)), path) cmd = ['mplay', '-C', '-T', '-R', '-r', str(int(frame_rate))] if sound_path: cmd.extend(('-a', sound_path)) cmd.append(houdini_style_path) proc = subprocess.Popen(cmd) # Inform the user that we want them to close the viewer before # publishing. This is really just to force them to look at it one last # time. We don't need to hold a reference to this one. self._viewer_msgbox = msgbox = QtGui.QMessageBox( QtGui.QMessageBox.Warning, 'Close Playblast Viewer', 'Please close the playblast viewer before publishing. It may take' ' a few seconds to launch...', QtGui.QMessageBox.Ignore, self ) msgbox.setWindowModality(Qt.WindowModal) msgbox.buttonClicked.connect(msgbox.hide) msgbox.show() # On OS X, `mplay` waits for you to close it. if sys.platform.startswith('darwin'): self._player_waiting_thread = thread = QtCore.QThread() def run(): proc.wait() self.viewerClosed.emit() thread.run = run thread.start() # On Linux, it does not. else: self._player_waiting_timer = timer = QtCore.QTimer() timer.singleShot(5000, self.viewerClosed)
def setFrames(self, path): # The easy part. super(Widget, self).setFrames(path) # Open a viewer, and wait for it to close. sound_path = get_sound_for_frames(path) or get_current_sound() frame_rate = cmds.playbackOptions(q=True, framesPerSecond=True) houdini_style_path = re.sub(r'(#+)', lambda m: '$F%d' % len(m.group(1)), path) cmd = ['mplay', '-C', '-T', '-R', '-r', str(int(frame_rate))] if sound_path: cmd.extend(('-a', sound_path)) cmd.append(houdini_style_path) proc = subprocess.Popen(cmd) # Inform the user that we want them to close the viewer before # publishing. This is really just to force them to look at it one last # time. We don't need to hold a reference to this one. self._viewer_msgbox = msgbox = QtGui.QMessageBox( QtGui.QMessageBox.Warning, 'Close Playblast Viewer', 'Please close the playblast viewer before publishing. It may take' ' a few seconds to launch...', QtGui.QMessageBox.Ignore, self) msgbox.setWindowModality(Qt.WindowModal) msgbox.buttonClicked.connect(msgbox.hide) msgbox.show() # On OS X, `mplay` waits for you to close it. if sys.platform.startswith('darwin'): self._player_waiting_thread = thread = QtCore.QThread() def run(): proc.wait() self.viewerClosed.emit() thread.run = run thread.start() # On Linux, it does not. else: self._player_waiting_timer = timer = QtCore.QTimer() timer.singleShot(5000, self.viewerClosed)
def setFrames(self, path): # The easy part. super(Widget, self).setFrames(path) # Open a viewer, and wait for it to close. sound_path = get_sound_for_frames(path) or get_current_sound() frame_rate = cmds.playbackOptions(q=True, framesPerSecond=True) # Resolve globs into ####. if '*' in path: prefix, postfix = path.split('*', 1) paths = glob.glob(path) pattern = '%s(.+?)(\d+)%s$' % (re.escape(prefix), re.escape(postfix)) for found in paths: m = re.match(pattern, found) if m: path = '%s%s%s%s' % (prefix, m.group(1), '#' * len(m.group(2)), postfix) break else: raise ValueError('cannot identify length of frame padding', paths[0]) # Replace #### with %04d for RV. rv_style_path = re.sub(r'(#+)', lambda m: '%0' + '%d' % len(m.group(1)) + 'd', path) cmd = ['rv', '[', rv_style_path, '-fps', str(frame_rate), ']'] if sound_path: cmd.extend(['-over', '[', sound_path, ']']) # fix for launching rv from maya on mac # http://www.tweaksoftware.com/static/documentation/rv/current/html/maya_tools_help.html#_osx_maya_2014 env = dict(os.environ) if 'QT_MAC_NO_NATIVE_MENUBAR' in env: del env['QT_MAC_NO_NATIVE_MENUBAR'] print subprocess.list2cmdline(cmd) proc = subprocess.Popen(cmd, env = env) # Inform the user that we want them to close the viewer before # publishing. This is really just to force them to look at it one last # time. We don't need to hold a reference to this one. self._viewer_msgbox = msgbox = QtGui.QMessageBox( QtGui.QMessageBox.Warning, 'Close Playblast Viewer', 'Please close the playblast viewer before publishing. It may take' ' a few seconds to launch...', QtGui.QMessageBox.Ignore, self ) msgbox.setWindowModality(Qt.WindowModal) msgbox.buttonClicked.connect(msgbox.hide) msgbox.show() # On OS X, `mplay` waits for you to close it. if sys.platform.startswith('darwin'): self._player_waiting_thread = thread = QtCore.QThread() def run(): proc.wait() self.viewerClosed.emit() thread.run = run thread.start() # On Linux, it does not. else: self._player_waiting_timer = timer = QtCore.QTimer() timer.singleShot(5000, self.viewerClosed)
def setFrames(self, path): # The easy part. super(Widget, self).setFrames(path) # Open a viewer, and wait for it to close. sound_path = get_sound_for_frames(path) or get_current_sound() frame_rate = cmds.playbackOptions(q=True, framesPerSecond=True) # Resolve globs into ####. if '*' in path: prefix, postfix = path.split('*', 1) paths = glob.glob(path) pattern = '%s(.+?)(\d+)%s$' % (re.escape(prefix), re.escape(postfix)) for found in paths: m = re.match(pattern, found) if m: path = '%s%s%s%s' % (prefix, m.group(1), '#' * len(m.group(2)), postfix) break else: raise ValueError('cannot identify length of frame padding', paths[0]) # Replace #### with %04d for RV. rv_style_path = re.sub(r'(#+)', lambda m: '%0' + '%d' % len(m.group(1)) + 'd', path) cmd = ['rv', '[', rv_style_path, '-fps', str(frame_rate), ']'] if sound_path: cmd.extend(['-over', '[', sound_path, ']']) # fix for launching rv from maya on mac # http://www.tweaksoftware.com/static/documentation/rv/current/html/maya_tools_help.html#_osx_maya_2014 env = dict(os.environ) if 'QT_MAC_NO_NATIVE_MENUBAR' in env: del env['QT_MAC_NO_NATIVE_MENUBAR'] print subprocess.list2cmdline(cmd) proc = subprocess.Popen(cmd, env=env) # Inform the user that we want them to close the viewer before # publishing. This is really just to force them to look at it one last # time. We don't need to hold a reference to this one. self._viewer_msgbox = msgbox = QtGui.QMessageBox( QtGui.QMessageBox.Warning, 'Close Playblast Viewer', 'Please close the playblast viewer before publishing. It may take' ' a few seconds to launch...', QtGui.QMessageBox.Ignore, self) msgbox.setWindowModality(Qt.WindowModal) msgbox.buttonClicked.connect(msgbox.hide) msgbox.show() # On OS X, `mplay` waits for you to close it. if sys.platform.startswith('darwin'): self._player_waiting_thread = thread = QtCore.QThread() def run(): proc.wait() self.viewerClosed.emit() thread.run = run thread.start() # On Linux, it does not. else: self._player_waiting_timer = timer = QtCore.QTimer() timer.singleShot(5000, self.viewerClosed)