Wednesday, January 30, 2013

meTools for Afanasy

Recently, I've updated a bit Maya's Python scripts for Afanasy. ver. 0.4.5 ver. 0.3.5
Sources are located at:

Now, both scripts have similar set of features and functionality:
- Maya's render layers support
- export compressed .mi (.vrscene) files
- deferred .mi (.vrscene) generation
- distributed rendering on render farm using Afanasy render manager

Render Layers

Now it's possible to render active render layer (even non renderable) or export separate .mi (.vrscene) files for all renderable render layers

Export compressed .mi files

Due to unknown reason, Maya's documentation for Mayatomr MEL command does not mention any descriptions for -compressed option. But Maya's file exporter to mentalray format has a corresponding OptionMenu control with ability to choose compression level: 'Off', 'GzipBestSpeed', 'GzipDefault', 'GzipBest'.
So, this flag realy exists and works within Maya GUI.
But in case when someone tries to genereate compressed .mi files from command line e.g.:
Render -r mi -compressed 6 -binary 1 -file outfile.mi
Maya will report the error  ' -compressed is invalid flag '... Maya 2012, 2013 -- still are treating this flag as unsupported. It's very strange...
Fortunately I've found a nice tip at
You have to edit the file $MAYA_LOCATION/bin/rendererDesc/miRenderer.xml.
Inside section,
<sep desc="Export:"></sep&gt
add the follwing line:
<mel h="Compression level: 0='Off', 1='GzipBestSpeed', 6='GzipDefault', 9='GzipBest' 
" n="compression" p="1" s="$opt +=" -compression %1"" t="int"&gt </mel&gt

Deferred .mi (.vrscene) generation

If you have $MAYA_LOCATION/bin/Render  available in $PATH system environment variable on  computers in your farm with 'mayatomr' or 'mayatovray' service enabled, now it's possible to generate .mi (.vrscene) on remote hosts. You can split sequence by tasks size parameter (e.g. 5 per host), and after each portion of files is finished, other hosts (with 'mentalray' or 'vray' service) will start to render them.

 Here is example for mentalray afanasy job with deferred scene generation:

 And VRay afanasy job with deferred scene generation:

Distributed rendering

If Remote Hosts parameter is not empty (you can place here 'hardcoded' space separated list of desired hosts), the script will insert these hosts to command line for distributed render. But in this case Afanasy will know nothing about usage of these hosts.
Otherwise (with empty string), special keyword @AF_HOSTS@ will be added to command line, and hosts list will be dynamicaly replaced by Afanasy during rendering depending of available free hosts with corresponding service ('mentalray' or 'vray')

Mentalray distributed rendering job example:

VRay distributed rendering job example:


  1. Replies
    1. Yes.
      I have some plans to add similar script for render by Arnold, as soon as will have a spare time ;)

    2. BTW. While I've tried to find a free time, Timur already has converted meVrayRender to meArnoldRender!
      Now all scripts are moved to "cgru\plugins\maya" in GitHub repository

  2. Hello,

    I'm trying to make Afanasy work with Vray for Maya.
    Using the CGRU plugin and launching the job with Maya Batch it works perfect but when I try to render with meVRayRender (after generating the .vrscene) I think there is a problem with my environnement variable because the logout from Afanasy tells me that Vray is not recognised as a renderer... So my question is what did you do to make it work ? :D

    I've already asked Timur about my problem but he doesn't work with VRay.

    By the way I have created a little blog about how to setup a renderfarm and use it with open source software like Afanasy and Natron :
    And of course I'm using Afanasy that's why I need to make it work with Vray !

    Here is my mail if you need :

    Thanks for your help

    1. Nice blog, Jonathan!
      Most problems are with environment variables...
      "afrender" keeps its own copy of environment, hence you need restart it everytime,
      when you edit environment variables.