Announcement

Collapse
No announcement yet.

using RT and backburner

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • using RT and backburner

    We have backburner running on the same machines as RT. This causes a bit of a problem for some. For us, the renderings on backburner usually have a higher priority. The problem is, you never know when someone is using VrayRT. We have coworkers out of country using backburner also.

    After a little thought, I figured I'd just write a script of some sort that handles the problem for me. I thought I'd share it here.
    It's an AHK file (that's autohotkey script). I placed a shortcut to it on all the machines and it also will update itself every time I add something to it, which is also nice. you can compile the file into an exe, but then you can't update it automatically. In fact, you can't even delete it if it's in use by another machine. So I had to install autohotkey on farm, but I like the software, so it's all good.

    Code:
    #SingleInstance , force	;you can only run one of these scripts at a time.
    
    FileGetTime , FileOrigTime , %A_ScriptFullPath%
        ;first record the time this script was saved.
    SetTimer , CheckScriptMod , 15000
        ;run this subRoutine every 15 seconds
    
    SetTitleMatchMode 2
    
    
    Loop,
    {
    	Process, exist, 3dsmax.exe   ;is max running
    	MaxPID = %ErrorLevel%
    	if MaxPID != 0  ;if max is running, close vray stuff
    		{
    			 Process, close, vrayrtspawner.exe
    			 Process, close, vray.exe
    		}
    	
    
    	else IfWinExist , HyperShot
    		{
    			Process, close, vrayrtspawner.exe
    			Process, close, vray.exe
    		}
    
    	else  ;if max is Not running, see if vray spawner is running
    		{
    			Process, exist, vrayrtspawner.exe
    			rtPID = %ErrorLevel%
    			if rtPID = 0  ;if spawner is not running, run it
    				{
    					Run "C:\Program Files\Chaos Group\V-Ray\RT for 3ds Max 2010 for x64\bin\vrayrtspawner.exe"
    					MsgBox ,,Success,VrayRT Spawner is running, 5 ;msgbox times out after 5 sec
    				}
    		}
    
    	
    		Sleep 15000  ;wait fifteen seconds, then run this check again
    
    }
    
    CheckScriptMod:
    
    	FileGetTime , FileModifiedTime , %A_ScriptFullPath% 
    
    	IfGreater , FileModifiedTime , %FileOrigTime% ;check if time of this file is newer than original
    		{
    			MsgBox ,,,This script has been updated so it will now reload. ,5
    			Reload
    		}
    	Else 
    		Return 
    
    
    #Esc::ExitApp
    I didn't put an incredible amount of notes in this, so here's the quick rundown.

    First part gets current script time and records it for later in case you want to autoupdate it.
    Set title mode 2 reads any part of the title so it doesn't have to match exactly.
    Loop -
    if max opens, close vrayRT stuff
    we have one machine that sometimes uses hypershot, so i threw that in there too. Just delete it or comment it out if you don't need it. Won't hurt anything though to leave it.
    OK, if max isn't running open the RT spawner (which in turn opens vray.exe) if it's not already running.
    Wait 15 seconds then check that loop again.

    The timer in the beginning runs the subroutine at the bottom every 15 seconds.
    It gets the time again and compares it to the old time. If the new time is bigger than the old time the script reloads itself and starts again.

    There are 2 message box alerts in there, but they go away after 5 seconds.

    Last line just means, if you hit windows key + Esc, it will just close the script.



    So that's it. I thought I'd share it in case anyone else might want to use it. Hopefully it helps someone else out. I'm not much of a programmer, so it took me a while. There's probably some more efficient ways to get some of this done also, but I'm not seeing much for resources taken when it's in use.
Working...
X