Exemple #1
0
    def screen_capture(self, local=True):
        # Import api modules
        import maya.OpenMaya as api
        import maya.OpenMayaUI as apiUI

        # Grab the last active 3d viewport
        view = apiUI.M3dView.active3dView()

        # Change the current time to get the view to refresh
        import time
        current_time = currentTime(query=True)
        time.sleep(0.25)
        currentTime(current_time+1, edit=True)
        time.sleep(0.25)
        currentTime(current_time, edit=True)

        # Read the color buffer from the view, and save the MImage to disk
        image = api.MImage()
        view.readColorBuffer(image, True)

        if local:
            file_path = "C:/Temp/%s.%s_%s.png" % (self.sequence.code, self.shot.code, self.shotfile.process)
        else:
            file_path = files.local_file(files.dm(self.movie.thumbnail))
            # Make sure the directory is created first
            if not os.path.exists(os.path.dirname(file_path)):
                try:
                    os.makedirs(os.path.dirname(file_path))
                except:
                    log.warning("Couldn't create directory %s" % os.path.dirname(file_path))
                    return None

        image.writeToFile(file_path, 'png')
        return file_path
Exemple #2
0
 def local_file(self):
     return "%s/%s.%s_%s.mov" % (files.local_file(self.local_path, self.sequence, self.shot, self.shotfile.process))
Exemple #3
0
 def local_path(self):
     return files.local_file("C:/temp") # TODO: this should return a local version of the server version
Exemple #4
0
    def execute(self, local=True):
        # Shotfile needs to save itself first, then we can create a movie file
        # that we use to save the resulting playblast to

        currentTime(self.shot.start)

        # Deselect everything
        selected = ls(selection=True)
        select(deselect=True)

        if not local:
            # Create a movie file for this shot - this gives us the filenames, paths, and
            # everything else we require to do a playblast

            self.movie = MovieFile(shotfile=self.shotfile.url, approved=False, daily=False)
            self.movie = self.movie.create()

        # Setup options
        textured = menuItem("op_PlayblastTexturesChk", query=True, checkBox=True)
        editorial_range = menuItem("op_PlayblastEditorialRangeChk", query=True, checkBox=True)

        # Bring up the playblast window to capture a single frame thumbnail
        thumb_win, viewport_name = playblast_window(process=self.shotfile.process,
                width=int( self.width * 0.15), height=int(self.height * 0.15), textured=textured)
        thumb_image = self.screen_capture(local=local)

        # Bring up the playblast window
        pb_win, viewport_name = playblast_window(process=self.shotfile.process, textured=textured)
        if local:
            movie_file = self.local_movie_file()
        else:
            movie_file = files.local_file(files.dm(self.movie.movie_file))

        # Get the soundfile in the timeline
        sound_file = timeControl("timeControl1", query=True, sound=True)
        
        if editorial_range:
            output_movie = playblast(
                    format="qt", filename=movie_file,
                    sound=sound_file,   
                    sequenceTime=0, clearCache=0, viewer=1, 
                    showOrnaments=0, fp=4, percent=100, compression="Motion JPEG A", quality=70,
                    forceOverwrite=True, startTime=self.shot.start, endTime=self.shot.end+1 )
        else:
            # Just playblast what's in the timeline
            output_movie = playblast(
                    format="qt", filename=movie_file,
                    sequenceTime=0, clearCache=0, viewer=1, 
                    showOrnaments=0, fp=4, percent=100, compression="Motion JPEG A", quality=70,
                    forceOverwrite=True)
        evalDeferred('from pymel.core import deleteUI; deleteUI("%s")' % pb_win)

        if not local:
            # This goes to the server - setup server based paths, and copy files
            self.shotfile = self.shotfile.save()


            # Move the thumbnail and the movie file to the appropriate place(s)

            log.info("Copying thumbnail from %s to %s" % (thumb_image, files.dm(self.movie.thumbnail)))
            log.info("Copying playblast movie from %s to %s" % (output_movie, files.dm(self.movie.movie_file)))
            shutil.copy(thumb_image, files.dm(self.movie.thumbnail))
            shutil.copy(movie_file, files.dm(self.movie.movie_file))

        # Reset the selected items
        select(selected)

        # Finally, playback the resulting movie file
        self.playback(local=local)