Friday, 2 January 2015

Playing a sound file after rendering an animation in OctaneRender for Poser

I had a request from a user wanting to play a sound file once the rendering of an animation as complete in OctaneRender for Poser.  This can be done with a python script:

   
 import winsound  
 import time  
 import threading  
 from threading import Thread, Event  
   
 class CheckAnimationFinishedThread(Thread):  
   def __init__(self, event):  
     Thread.__init__(self)  
     self.stopped = event  
   
   def run(self):  
     while not self.stopped.wait(0.5):  
       if not octanePlugin.UiManager.GetSetupForm().renderingAnimation:  
         # Stop the thread  
         stopFlag.set()  
           
         # Play the sound file  
         winsound.PlaySound("C:\Users\Public\Documents\Poser Pro 2014 Content\Runtime\LipSync\Audio Files\HiThere.wav", winsound.SND_FILENAME)  
         
 octanePlugin = __import__("OctaneRender for Poser")   
 if not octanePlugin.UiManager.IsSetupWindowOpen():  
   print "Setup Window not open"  
 else:  
   octanePlugin.UiManager.GetSetupForm().EventRenderAnimation(None)  
     
   # Start the thread to check for the end of rendering the animation  
   stopFlag = Event()  
   thread = CheckAnimationFinishedThread(stopFlag)  
   thread.start()  
   

Copy the above code into a file called RenderOctaneAnimation.py and save to the C:\Program Files\Smith Micro\Poser Pro 2014\Runtime\Python\poserScripts\ScriptsMenu folder (assuming Poser is installed in C:\Program Files).  Then open the OctaneRender for Poser plugin, and run the above script from the Poser->Scripts menu->RenderOctaneAnimation.  This will start the plugin rendering the animation, and once complete, it will play the HiThere.wav file.  You can play any file by changing the code above.