Converting EMDL files


Recently a few customers have asked Autodesk support about converting their Softimage EMDL files, and whether they could somehow get Softimage licenses to do it. (One Autodesk person even asked me whether I know anyone who could answer Softimage questions! 😉

You actually don’t need a license, because you can do it with xsibatch. Just add the -processing flag to do it without using a license.

xsibatch.exe -processing -script "S:\solidangle\softimage\convert_emdl.pys" -main "main"

Here’s an example script that loads a model and exports it to Alembic:

def main():
Application.ImportModel("S:\Program Files\Autodesk\Softimage 2015 SP2\Data\XSI_SAMPLES\Models\Jaiqua.emdl", "", "", "", "", "", "")

path = "S:\Projects\softimage\support\Models\{0}.abc".format( Application.Selection(0).Name )

model = "B:{0}".format( Application.Selection(0).Name )

Application.AbcExport( path, 1,2, model, False, "Ogawa", "Color, Scale, Size, PointVelocity, Orientation, AngularVelocity, Shape, StrandPosition, StrandVelocity, StrandDeform, StrandOrientation, StrandUpVector, StrandColor, StrandSize, ColorAlongStrands", "Materials, MaterialID, PointUserMotions", "")

PS Here’s the Softimage SDK help

Softimage standalone licenses and Arnold


Someone asked me if they could use Arnold with a standalone Softimage license.

Yes, of course you can. You can use Arnold with a trial version of Softimage; the Arnold license is completely separate. As long as you can start Softimage and load the SItoA plugin, you can render with Arnold.

The SItoA plugin itself is not licensed. It isn’t until you start a render that Arnold checks out a license.

So, how does it work if you have one Standalone Softimage license and five Arnold licenses?

  • You use your standalone license to run Softimage, build your scenes, and set up your lighting, shading, and texturing. Every time you do a render region, or render a frame, Arnold will check out a license (and check it back in when the render is finished).
  • To set up a five-node Arnold render farm, you don’t need any more Softimage licenses, because you’ll use xsibatch -processing -render to do your batch rendering. Just install Softimage on five more machines. You don’t need to activate Softimage or anything. You’ll still be able to run xsibatch -processing -render on those machines, because -processing skips the licensing check.

Unlimited batch rendering with xsibatch -processing


Hat tip: Andy Jones on the Softimage mailing list

You can use xsibatch -processing to render scenes with third-party renderers like Arnold. With -processing, xsibatch uses a Processing token instead of a Batch license, so you’re not limited by the number of Batch licenses you happen to have. Back in the days before third-party renderers, -processing for was for non-rendering tasks. Now it’s for non-mental ray tasks!

I was sure I tested this long ago, but obviously I must have made a mistake on my command line.

xsibatch -processing -render //server/project/Scenes/example.scn

=======================================================
 Autodesk Softimage 11.1.57.0
=======================================================

License information: using [Processing]
# INFO : [sitoa] SItoA 2.7.1 win loaded.
# INFO : [sitoa] Arnold 4.0.12.1 detected.

Here’s actual proof in the form of a screenshot 🙂

xsibatch_processing_render

Writing a python script for processing scenes with xsibatch


Here’s the basic skeleton of a Python script that calls xsibatch -processing -script on all scene files in a given folder.

Python command line:
The python script takes two arguments: the root folder for the location of the scene files, and the name of the script file to run with xsibatch -script.

python process_scenes.pys --dir ""C:\Program Files\Autodesk\Softimage 2013 SP1\Data\XSI_SAMPLES\Scenes" --script "test.pys"

process_scenes.pys:
The python script takes care of finding all the scene files, and then running xsibatch -processing -script on each .scn file.

import os
import fnmatch
import subprocess
import sys
import getopt

XSI_BINDIR=r"C:\\Program Files\\Autodesk\\Softimage 2013 SP1\\Application\\bin"

opts, extraparams = getopt.getopt(sys.argv[1:], "d:s:", ["dir=","script="]) 

#
# Get root directory to scan for scene files
#
SCENES_DIR="C:\\Program Files\\Autodesk\\Softimage 2013 SP1\\Data\\XSI_SAMPLES\\Scenes\\OLD"
SCRIPT="test1.pys"

for o,p in opts:
  if o in ['-d','--dir']:
     SCENES_DIR = p
  elif o in ['-s','--script']:
     SCRIPT = p

#
# Generator function for finding files
#
def find_files(directory, pattern):
     for root, dirs, files in os.walk(directory):
         for basename in files:
             if fnmatch.fnmatch(basename, pattern):
                 filename = os.path.join(root, basename)
                 yield filename

#
# Open each scene file and run the specified script
#
for scn in find_files(SCENES_DIR, '*.scn'):
	sXsiBatch = "%s\\xsibatch" % XSI_BINDIR
	subprocess.call( [ sXsiBatch, '-processing', '-script', SCRIPT, '-args', '-sSceneName', scn ] )

Softimage script test.pys:
A simple test script to run with xsibatch. Note that because the function is named “main”, I don’t have to specify that on the xsibatch command line. I just have to specify the arguments.

def main( sSceneName ):
	LogMessage( sSceneName )	

Setting up Softimage for network rendering


I get asked this question from time to time. It’s actually pretty straightforward to set up…it’s managing the render jobs that may take more effort.

  1. On each render node, install a network-licensed version of Softimage.
  2. During the install, on the Product Information page:

    • Choose Network License.
    • Enter your serial number and the product key 590D1.
    • Enter the name of the license server computer.

Done. It’s all set up now, but there’s a few things you should check/consider:

  • Check that you can run xsibatch on the render nodes and get a license.
    If you have any problems, here’s some troubleshooting tips for xsibatch licensing.
  • Xsibatch needs to have read/write access to wherever you store your Softimage scene files and projects, and wherever you decided to output the rendered images.
    For example, you could have a separate file server for scenes and render output, or it could be the local workstation where you run Softimage.
  • Third-party addons, plugins, and shaders need to be available to the render nodes, either via a shared workstation or by installing them on the render node.
    Note that the user account used to run xsibatch will have a Softimage user folder on the render node.
  • You need a way to manage the render jobs that run on the render nodes. There are a range of possible ways to do this:
    • Manually starting xsibatch on each render node.
      You could either specify specific framesets to render, or use the –skip flag to tell xsibatch to skip frames that are already rendered [by other render nodes]
      For example:

      xsibatch –render “//server/project/scenes/Example.scn” –frames 1-10
      xsibatch –render “//server/project/scenes/Example.scn” –skip
    • Hand-rolling your own tools/scripts to start render jobs (for example, using pstools to start xsibatch jobs on the render nodes, or generating batch files to kick off render jobs)
    • Purchasing render management software (such as Royal Render—you may want to try the demo version)

Setting workgroups at startup


Here’s a simple, low-tech way to connect to specific workgroups at startup:

Instead of xsibatch -w or xsi -w, you could modify setenv.bat to create another .xsipref file in %XSI_USERHOME%\Data\Preferences. Whatever is in that file will override what is in default.xsipref.

So, for example, you could do this:

echo data_management.workgroup_appl_path	= C:\Users\blairs\MyWorkgroup >  %XSI_USERHOME%\Data\Preferences\workgroups.xsipref

or you could use an environment variable:

echo data_management.workgroup_appl_path	= %MY_XSI_WORKGROUPS%  >  %XSI_USERHOME%\Data\Preferences\workgroups.xsipref

This does require you to edit setenv.bat, which isn’t so useful if you have a lot of seats. In that case, if you use a network deployment, you could deploy a %XSI_BINDIR%\SiteDeploy.bat file and use that to echo out the workgroup preference.

Creating a batch file for rendering frame sets with xsibatch


Here’s a quick and dirty way to get a batch file that renders a scene in chunks (by “chunks” I mean something like “10 frames at a time”).

var start = 1;
var end = 76;
var step = 10;

var sCmdLine = "call \"%BATCH%\" -render \"%SCN%\"";

LogMessage( "set BATCH=" + Application.InstallationPath( siFactoryPath ) + "\\Application\\bin\\xsibatch.bat" );
LogMessage( "set SCN=" + Application.ActiveProject.ActiveScene.FileName.Value );
for ( var i=start; i<end; i=i+step )
{
	var x = i + step-1;
	x = (x > end) ? end : x;
	LogMessage( sCmdLine + " -frames " + i + "-" + x );
}

This will give you:

// INFO : set BATCH=C:\Program Files\Autodesk\Softimage 2012 SP1\Application\bin\xsibatch.bat
// INFO : set SCN=C:\Users\blairs\Documents\Support\My_Support\Scenes\PolygonReduction_CAV.scn
// INFO : call "%BATCH%" -render "%SCN%" -frames 1-10
// INFO : call "%BATCH%" -render "%SCN%" -frames 11-20
// INFO : call "%BATCH%" -render "%SCN%" -frames 21-30
// INFO : call "%BATCH%" -render "%SCN%" -frames 31-40
// INFO : call "%BATCH%" -render "%SCN%" -frames 41-50
// INFO : call "%BATCH%" -render "%SCN%" -frames 51-60
// INFO : call "%BATCH%" -render "%SCN%" -frames 61-70
// INFO : call "%BATCH%" -render "%SCN%" -frames 71-76

Now all you have to do is paste it into a text editor, do a search and replace to get rid of the “// INFO : ” (that’s the dirty part), and you’ve got a batch file that you can use to render your scene.

Python version:

from siutils import si		# Application
from siutils import siproj	# ActiveProject2
from siutils import siut	# XSIUtils
from siutils import C		# win32com.client.constants

start = 1
end = 76
step = 10

sCmdLine = 'call "%BATCH%" -render "%SCN%"'
print "set BATCH=" + siut.BuildPath( si.InstallationPath( C.siFactoryPath ), "Application", "bin", "xsibatch.bat" )
print "set SCN=" + si.ActiveProject.ActiveScene.FileName.Value
for i in range(start,end,step):
	x = i + step-1
	x = end if (x > end) else x
	print "%s %s %s %s %s" % (sCmdLine, " -frames ", i, "-",x )

Closing error dialog boxes that pop up during batch rendering


If xsibatch hits a runtime error or stops responding, Windows will pop up a dialog box that will sit there until some dismisses it.

On the XSI mailing list last year, Alan Fregman posted an AutoHotKey script that kills Visual C++ Runtime error messages when they pop-up.

AutoHotKey is free, so you could adapt that script to handle other pop-up dialogs, like the XSIBatch.exe has topped working message.

Another possibility would be to set the HKCU\Software\ Microsoft\Windows\Windows Error Reporting\DontShowUI registry key. I haven’t tried it, but I read about it here.

Tip: To test the AutoHotKey script, double-click the .exe to start the AutoHotKey script. You should see an icon in your Windows task bar. Then in Softimage, run this JScript:

XSIUIToolkit.MsgBox( "Runtime Error!" , siMsgOkOnly, "Microsoft Visual C++ Runtime Library");

The pop-up message box should close immediately.

Try exiting the AutoHotKey script (from the task bar). Then run the JScript again.,
Or just change “Runtime Error” to “All is good”, and notice that the message box is not automatically closed.