Ejemplo n.º 1
0
 def execute(self, percent=100, textured=False, dynamics_enabled=False, create_version=False, comment=None, batch=False):
     debug = 0
     # First, make sure we're in GUI mode - can't playblast otherwise
     from pymel.core.general import about
     if about(batch=True):
         log.warning( "Can't perform playblast in batch mode - requires GUI to run")
         return
     # We're in GUI mode, continue with playblast
     log.info( "Performing playblast of shot %s" % self.shot)
     # Create version if we're playblasting to snapshot for approvals
     if create_version:
         log.info( "Publishing shot %s prior to playblast" % self.shot)
         if not debug:
             if comment or batch:
                 self.shot.vault()
             else:
                 from internal.publishing import gui as publish_gui
                 published = publish_gui.publish_shot_gui(self.shot)
                 if not published:
                     log.warning( "Playblast of %s was cancelled" % self.shot)
                     return False
     # Store a list of selected objects, to restore at the end
     # Deselect all objects, so that no wireframes show
     selected = ls(selection=True)
     select(deselect=True)
     # Set the start and end timerange appropriately
     self.set_timerange(create_version = create_version)
     # Construct the window to playblast through - this stuff is in the 
     # core.gui.animation module
     from core.gui import animation as anim_gui
     playblast_window, model_editor = anim_gui.playblast_window( self.shot.process, self.width, self.height, textured=textured, dynamics_enabled=dynamics_enabled)
     # Need to set then reset the image format in the render globals - for some stupid reason, Autodesk
     # uses this setting for playblasts as of 2011 - didn't for the last 15 years.
     default_render_globals = ls('defaultRenderGlobals')[0]
     prev_image_format = None
     if default_render_globals:
         log.info("Setting render globals to IFF for playblast")
         prev_image_format = default_render_globals.imageFormat.get()
         default_render_globals.imageFormat.set(7) # 7 == IFF
     # Do the actual playblast - have to defer the evaluation of the 
     # command, to give the window time to draw
     playblast_finished = playblast(format="iff", filename=self.local_pblast_name, viewer=False, 
             showOrnaments=False, fp=4, percent=100, fo=True, quality=100)
     # Reset the render globals to what the user had it set to before
     if prev_image_format:
         log.info("Resetting render globals to user defined value: %s" % prev_image_format)
         default_render_globals.imageFormat.set(prev_image_format)
     if not playblast_finished:
         log.warning("User cancelled the playblast for %s - not saving to snapshot" % self.shot)
         if selected:
             select(selected)
         return
     if create_version:
         # Publish the movie file to snapshot
         self.encode()
         self.publish()
     # Delete the playblast window now that we're done with it - 
     # use deferred to ensure that the playblast is done before 
     # deleting the window
     evalDeferred('from pymel.core import deleteUI; deleteUI("%s")' % playblast_window)
     # Restore selection
     if selected:
         select(selected)
     # Run RV on the resulting images - if we're in batch mode,
     # skip this, and if we're not creating a version in the DB,
     # then it's a local playblast - run RV on the local images
     # instead of on the movie in snapshot
     if not batch:
         if create_version:
             self.playback(movie=True)
         else:
             self.playback()
Ejemplo n.º 2
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)