Announcement

Collapse
No announcement yet.

Setting DR servers as pre-render MEL

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

  • Setting DR servers as pre-render MEL

    I'd like to run a pre-render MEL script which erases all DR servers registered and then adds the one I specify.

    Would this be possible?
    I see that you can add a server with the command vrayAddServer;, but how do you supply the IP address to this command?

    I'm on V-Ray for Maya 2.40.01, Maya 2014 (Windows and Linux).
    Best Regards,
    Fredrik

  • #2
    It's possible, but you must read what vrayAddServer() is doing. It's getting the information with vrayReadServers()/vrayReadServersStatus()/vrayReadServersPorts()... edit it, and then set it back with vraySaveServersInfo() and vraySaveServersInfo()
    V-Ray/PhoenixFD for Maya developer

    Comment


    • #3
      Hi Ivaylo and thank you,

      Okay I think I made it work. Some example Python code for anyone else who may want to do this.

      Code:
      def removeDRFiles():
      	userAppDir = cmds.internalVar(userAppDir=True)
      	# Delete files: server_list.tmp, server_status.tmp
      	filepath = os.path.join(userAppDir, 'server_list.tmp')
      	try:
      		os.remove( filepath )
      		print 'Removed ' + filepath
      	except:
      		print 'Unable to remove ' + filepath
      		
      	filepath = os.path.join(userAppDir, 'server_status.tmp')
      	try:
      		os.remove( filepath )
      		print 'Removed ' + filepath
      	except:
      		print 'Unable to remove ' + filepath
      
      
      def setHostVray(host):
      
      	mel.eval('string $server="' + host + '";')
      	mel.eval('string $serverList[] = vrayReadServers();')
      	mel.eval('string $serverStatusList[] = vrayReadServersStatus();')
      	
      	mel.eval('int $maxLen = vrayGetMaxStringLen($serverList);')
      	mel.eval('string $entry = vrayDRMakeServerEntry($maxLen, $server, "", "Enable");')
      	mel.eval('textScrollList -e -append $entry "vray_server_list";')
      	mel.eval('$serverList[size($serverList)] = $server;')
      	mel.eval('$serverStatusList[size($serverStatusList)] = "Enable";')
      				
      	mel.eval('vraySaveServersInfo($serverList, $serverStatusList);')
      
      	print 'Registered ' + host
      
      
      
      
      
      removeDRFiles() # Removes any previous server entries
      setHostVray('192.168.0.100') # Adds server 192.168.0.100
      Last edited by Fredrik Averpil; 10-11-2013, 11:31 AM. Reason: Formatting
      Best Regards,
      Fredrik

      Comment

      Working...
      X